Local Time Scale
v1.0
Last updated
Was this helpful?
v1.0
Last updated
Was this helpful?
LocalTimeScale
The LocalTimeScale
class is the thing that helps objects determine their final TimeScale
value. There are three main ways you'll utilize Local Time Scale objects.
Right click in your project and select Create/Magic Time/Time Scale
to create a new Scriptable Object.
With this pattern, all objects will be accessing the same runtime instance of these LocalTimeScale
objects. Use this for "Global" scales, as well as time scales that are meant to effect specific types of objects, such as "Enemies" or "Projectiles".
Any object that will be changing its time scale using Magic Time should implement IUseMagicTime
. Inheriting from MagicTimeUser
is likely a great option most of the time.
Simialr to the Time Zone objects, creating your own LocalTimeScale
enables more options and flexibility to help create the in-game experience you're looking for.
Each LocalTimeScale
includes UnityEvents
and other events you can subscribe to.
Since these objects are Scriptable Objects, in most cases you'll need to subscribe to the UnityEvents
at runtime, specifically subscribing to the instance
of the Scriptable Object that is created at runtime. Your object should reference the LocalTimeScale and add itself as a listener.
The Events
also include the LocalTimeScale
object, which is useful if you have one object that is subscribed to multiple LocalTimeScale
objects, and needs to know which one called the event.
Often the pre-created objects will populate the and lists of "Initial Time Scales".
The interface is implemented by . Each Magic Time User object will automatically create its own LocalTimeScale
, which you can think of as that objects internal clock.
LocalTimeScale
objects can be created at runtime as well. Classes like the demonstrate how this can be done.
Be sure to check out the page with examples on how to use this class.
LocalTimeScale
can be used to handle game-wide time scaling, including pausing.