Magic Time User Scripting
v1.0
I hope you find it easy to interact with a MagicTimeUser
object, using the properties and methods provided.
Check out the full MagicTimeUser
class for all the details on the methods and properties available.
Time Control
Most times you would usually use Time.deltaTime
to handle something related to this object, you will probably want to use the DeltaTime
property instead. This will return Time.deltaTime
scaled down by the magicTimeUser.TimeScale
. There are similar properties for FixedTime
and UnscaledDeltaTime
.
Time.unscaledDeltaTime
will return the last frame time without taking Time.timeScale
into account.
Main Time Properties
Here are some simple exampels of how you might use the main time properties.
Moving based on DeltaTime
DeltaTime
In this example, we have a generic Move() method which handles objects that may or may not have a MagicTimeUser component on them, selecting the appropriate DeltaTime
to use.
Adjusting object locomotion speed with InverseTimeScale
InverseTimeScale
We may not always want to scale values by the TimeScale
value. To achieve a "running in slow motion" effect, where the "Locomotion" animation is determined by the distance a character is moving, we must account for the TimeScale
.
We use the InverseTimeScale
to multiply the metersPerSecond
value. If TimeScale is not exactly 1f
, then InverseTimeScale
will either increase or decrease the metersPerSecond
value.
Then, we set the locomotion float
value on the Animator
to this animationSpeed.
Subscribing and Unsubscribing to other LocalTimeScale
objects
LocalTimeScale
objectsOften you may want to manually subscribe an object to another LocalTimeScale
. Or perhaps unsubscribe from one.
Grabbing and using the LocalTimeScale
of one object, from another class
LocalTimeScale
of one object, from another classSometimes you may wish to do something with the LocalTimeScale of another object.
Getting the GameObject
from a MagicTimeUser
GameObject
from a MagicTimeUser
In cases where you're interacting with MagicTimeUser
objects, you may have a need to get the GameObject
associated with that object. The GameObject
property on MagicTimeUser
does just that!
Of course, if you create your own class which derives from MagicTimeUser
, you could add new logic in order to return a different value, if that fits your game.
Last updated