9 – Intro to Movement

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”).

accelerate

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”).

Accelerate Towards

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.

 Change Velocity

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.

Move
Our sixth movement behavior is Interpolate. While Interpolate is not a traditional movement, it’s great for shifting immovable objects within a scene. This behavior changes the value of an attribute (which are discussed in a later tutorial) to a new value over a set duration. Typically, objects moved with Interpolate cannot be affected by any other movement behaviors while the Interpolate behavior is selected.  There are exceptions to this rule, of course, such as when two Interpolate behaviors trigger simultaneously.
 Interpolate
In addition to our six main methods, you can also achieve the movement of actors through the use of four other behaviors – “Change Attribute”, “Rotate”, “Rotate to Angle”, and “Rotate to Position”.  With “Change Attribute”, you can change the positional attribute of an actor to anything else.  This will achieve the immediate and instantaneous movement of an actor to an entirely new position, which makes it useful for portal-type or teleportation-type movements.  The “Rotate” suite of behaviors won’t move your actor through space, but will change its orientation; each of the three behavior options simply provides the flexibility of either specifying an angle, an X/Y coordinate, or creating a continuous rotation at a given speed.