Game Development Reference
In-Depth Information
Motion and path finding
Enemy movement is fairly easy, the same as pretty much everything else in
GameSalad. First off, we are going to drag in an Accelerate behavior, and set the
speed to 250 and its direction. When it comes to directions, 0 moves the actor right,
and 180 moves him left.
This is an easy way of moving our enemies around, but we are going to make things
a little more complex. Why? Well, when the enemy hits a block, he will just stop. We
don't want that. We want him to turn around and keep wreaking havoc:
1.
Create a new rule. The rule will be entitled Accelerate Forward , which will
be Attribute | self.Graphics.Flip Horizontally | is | false . Then drag
the Accelerate behavior into this rule.
2.
Copy and paste that rule, change it to Attribute | self.Graphics.Flip
Horizontally | is | true and change the direction to 180 .
Now we want to detect if he is stuck and can't move:
1. Create another rule, change the first condition to Attribute | self.
Graphics.Flip Horizontally | is | false , click on the + button to add
another condition, change that one to Attribute | self.Motion.Linear
Velocity.X | = 0 . This will now detect if he is facing forward, and not
moving, that is he's stuck.
 
Search WWH ::




Custom Search