Using packages like Rotate and Move, Move, and Mighty Animations can really assist in bringing the objects inside of your game world alive.
This tutorial will go over these three packages, starting with the simplest script and then onto the more advanced scripts.
Rotate And Move: Great for objects that are always moving/rotating
Move: Great for moving objects with more control (such as through events)
Mighty Animations: Great for an abundance of movement/rotations to create detailed animations
Rotate And Move
A simple script that allows you to do as so: Rotate and move objects.
This script can be attached to an object. It has seven different properties:
- Time: How long it takes for the rotation/movement to complete
- Pause: Should the rotation/movement pause between cycles?
- Initial Pause: Should there be an initial pause before the rotation/movement starts? (as this script operates on Init, your rotation/movement will start immediately in the game world, unless you enter a value for the initial pause)
- Rotation End: The x,y,z degrees for rotation
- Movement End: The x,y,z coordinates for movement
- Bounce: If true… When your rotation/movement ends, should it bounce backwards rather than starting over from the beginning (starting rotation/movement values)
- Mode: These options can help to smooth the transitions from start to end
If any of these properties seem a bit confusing, my best advice is to experiment with them.
I am going to add the rotateAndMoveScript onto an Apple entity and enter some rotation values.
Next, we can test our rotation on the Apple directly from the editor through ‘Simulate’:
Once ‘Simulate’ is check marked, the rotations will start and the Apple will be encompassed by a grid pattern.
Now, to perhaps make the rotation appear smoother, I can checkmark ‘Bounce’ and change the mode to ‘EaseInOut’:
This means that once the rotation is nearing complete, it will smoothly transition out. Once complete, it will start the ‘bounce’ (rotating backwards), and then almost immediately smoothly transition back into the rotation:
For the next example, I will be doing something a bit more useful, and will need the following mesh assets dragged into the game:
- Target Dummy
I have placed the Target Dummy on one end of the column, and slightly shifted it downwards as to hide the base of the dummy:
I am going to attach the rotateAndMoveScript onto the Target Dummy, and enter the following values:
The once standstill Target Dummy is now moving back and fourth across the column:
Much like the Rotate and Move package, the ‘Move’ package contains a script that allows you to move objects (but not rotate them) with more configuration and control.
Once I attach the Move script onto an object, I can see that it has seven default properties up front with an optional ‘Show Advanced’ property.
Many of these properties are similar to the Rotate and Move script, but are named differently:
- Move Vector = Movement End
- Move Time = Time
- Move Type = ‘Pingpong’ is essentially the same as ‘Bounce’. ‘Repeat’ would be the same as not using Bounce, and ‘Once’ is a one off movement
- Smooth Type = Similar to ‘Mode’
- Move on Start: Rotate and Move always starts on Start, but with the Move package we have the option of enabling or disabling this
- Start Delay = Initial Pause
- Pause Time = Pause
- Show Advanced: Additional optional config (not neccessary to use) to essentially randomize the above properties (movement coordinates, move time, start delay, pause time and so on.)
So what are the differences between ‘Move’ and ‘Rotate and Move’?
Most noticeably is that Rotate and Move operates on Init, whereas Move can either operate on Init or through an event being sent.
In other words, Rotate and Move is a great choice for objects that should always be moving in the game world.
Move may be a better choice for objects that should only move under certain circumstances (for example, a piece of floor that moves only after being stepped upon, or an Apple that moves only when the player has interacted with it.)
As an example, I have attached the Move script onto a piece of floor and set up a trigger to send the ‘Activate’ function On Trigger Enter.
Which gives the following result:
Additionally, you could stop movement On Trigger Exit.
Last but not least, we have…
Compared to the previous two scripts, Mighty Animations can also be used to rotate and move objects. It can also operate on Init or through events.
Where it most noticeably stands out though, is how you can set up many rotations and movements all within a single script.
There are also some unique options to control the playback of the animations:
You can also send events throughout the animation:
In conclusion, Mighty Animations may be more useful than the other two scripts if you are wanting to create detailed animations rather than doing some simple rotations and movements.
You can read the full guide for Mighty Animations here: Mighty Animations