Magic Time User
v1.0
Last updated
Was this helpful?
v1.0
Last updated
Was this helpful?
Magic Time User is a MonoBehaviour
which implements IUseMagicTime
. Objects which will utilize the Magic Time system should inherit from MagicTimeUser
, so they automatically work.
LocalTimeScale
Each MagicTimeUser
object will have its own LocalTimeScale
automatically. This is unique and specific to this object, and its value will be combined with any other Local Time Scales that this object subscribes to.
These are the main methods and properties you'll likely interact with most often.
DeltaTime
, FixedDeltaTime
, and UnscaledDeltaTime
will replace Time.deltaTime
, Time.fixedDeltaTime
, and Time.unscaledDeltaTime
in your code. Anywhere that you would have used Time.deltaTime
, you should use DeltaTime
instead.
TimeScale
is the actual scale currently set based on all of the subscribed LocalTimeScale
objects, compared to normal speed (Time.timeScale
= 1f
).
InverseTimeScale
is the value you would need to multiple TimeScale
by in order to get Time.timeScale
. This is useful for multiplying things that you don't want to be slowed down, when they otherwise would. (See the "animation" example in the page.)
Once added to your class, some fields will be exposed in the Inspector.
Whenever the combined TimeScale
value changes, the value of TimeScale
will transition to the new value.
This is how long the transition lasts. Set this value to 0f
to skip transitioning altogether.
This is the curve used for the transition, if you'd like to customize the experience.
This is the default time scale value for this objects LocalTimeScale
object.
Often you may want your object to subscribe to some LocalTimeScales
, but not others, depending on the type of object it is in your game. In my own project, I have "Enemy" and "Player" Local Time Scales, and characters of those types will subscribe to one or the other.
Here I have exposed two additional lists, one for the "Player" and one for the "Enemy". In my code, I ensure the character only subscribes to the correct list of LocalTimeScales
.
Check the page for more scripting documentation.
These are LocalTimeScale
Scriptable Objects which you want to subscribe to at runtime. These will connect to the instances of those objects via the in your scene.