As you saw earlier, there are numerous behaviors that control how actors move, interact, and behave within a scene or a game. In this tutorial, we’re going to learn more about a few specific movement behaviors that can help your actors move the way you want.
There are six primary behaviors dedicated to movement and each is tailored for a specific purpose.
The first behavior is “Accelerate”. Accelerate will gradually increase the movement rate of an actor until something else intervenes or the maximum velocity of the actor is reached. This behavior is very useful for movements that involve gravity, jumping, being thrust from a rocket, and more. In the Accelerate behavior, we can set a direction (chosen from 0 to 359 degrees), an acceleration rate, and whether the direction is relative to the actor or to the scene. Accelerate will continue to affect an actor as long as the conditions for the behavior are met (as we’ll discuss in our tutorial on “rules”).
The next behavior is “Accelerate Toward”. This behavior functions exactly like Accelerate, except instead of selecting a direction, we can select a set of x/y coordinates. This behavior has the advantage of being able to select the location of another object, as we’ll discuss later in our “attributes” tutorial. Like Accelerate, Accelerate Toward has the option to select an acceleration rate and whether the coordinates are relative to the scene or to the actor. Accelerate Toward will continue to affect an actor as long as the conditions for the behavior are met (as we’ll discuss in our tutorial on “rules”).
Our third behavior is “Change Velocity”. Like Accelerate, this behavior allows us to select a direction and whether or not it is relative to the scene or the actor. However, instead of accelerating at a constant rate, this behavior will instantly change the actor’s movement to a set velocity. Once this speed is set, however, other movement behaviors will act upon the actor, such as the acceleration of gravity, or friction resistance against another actor. Change Velocity is therefore a behavior that triggers, acts, and subsequently does nothing until it is triggered again. For example, imagine we have an actor accelerating from 0 to a maximum actor speed of 200 at a rate of 50 per second. After 1 second, the actor has accelerated to 50. At this point, we could have a Change Velocity behavior trigger, changing the actor’s speed immediately to 150. After 2 seconds, the actor would have accelerated another 50, for a final speed of 200 after 2 seconds. The Change Velocity behavior would have increased the actor’s speed to 150, but then allowed the “Accelerate” behavior to continue to act.
We’ll address our next two behaviors together: “Move” and “Move To”. These both function similarly to the “Change Velocity” behavior in that they set a direction and a speed for an actor. However, they act continuously upon an actor. As long as these behaviors are active, therefore, they will override (or cause the actor to temporarily ignore) movement behaviors like Accelerate, Accelerate Toward, and Change Velocity. Move and Move To also have the option to control how they interact with other movement behaviors. With “Additive” selected, multiple Move or Move To behaviors will combine both their velocity and direction. With “Stacked” selected, only the most recently triggered Move or Move To behavior will control the actor. Like Accelerate, Move offers the option to select a direction, while Move To (like Accelerate Toward) allows the entry of a specific x/y coordinate, so the actor can move towards a point like the mouse position or another actor.