Magic Time User
v1.0
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.
You can create your own implementation logic either by creating your own IUseMagicTime
class, or creating a new class which derives from MagicTimeUser
and overrides the methods you'd like to customize.
"Local" LocalTimeScale
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.
Main Methods and Properties
These are the main methods and properties you'll likely interact with most often.
Time Properties
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 Magic Time User Scripting page.)
Check the Magic Time User Scripting page for more scripting documentation.
Inspector Options
Once added to your class, some fields will be exposed in the Inspector.
Initial Time Scales
These are LocalTimeScale
Scriptable Objects which you want to subscribe to at runtime. These will connect to the instances of those objects via the Magic Time Manager in your scene.
Transition Settings
Whenever the combined TimeScale
value changes, the value of TimeScale
will transition to the new value.
Transition Duration
This is how long the transition lasts. Set this value to 0f
to skip transitioning altogether.
Transition Curve
This is the curve used for the transition, if you'd like to customize the experience.
Default Time Scale
This is the default time scale value for this objects LocalTimeScale
object.
Customization Example
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
.
Last updated