> For the complete documentation index, see [llms.txt](https://infinitypbr.gitbook.io/magic-pig-games/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://infinitypbr.gitbook.io/magic-pig-games/magic-time-local-time-scale/quick-start.md).

# Quick Start

Getting working local time scales is fairly quick, and can be accomplished in just a few steps.

{% embed url="<https://youtu.be/PgsRP3bPHR4>" %}

## Create Your Class

Start by ensuring your class implements [`IHaveLocalTime`](/magic-pig-games/magic-time-local-time-scale/magic-time-user/ihavelocaltime.md), or inherits from [`MagicTimeUser`](/magic-pig-games/magic-time-local-time-scale/magic-time-user.md). Below, our "Sphere" class inherits from `MagicTimeUser`, so has exposed fields and helpful methods ready to go.

<figure><img src="/files/5CftF71JbPLoal3DZcrS" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/1GqlrcfAgty9ZdhT5Tfo" alt=""><figcaption></figcaption></figure>

## Create Project-wide Time Scales

In a new project folder to hold your Time Scale objects, right-click and select **Create/Local Time Scale/ Time Scale** to create a new `LocalTimeScale` scriptable object.

Name this one "Global" for the purposes of this walkthrough. Often you'll want a Global time scale which can influence nearly all objects in your project. You can also create any additional Time Scale objects now as well.

<figure><img src="/files/DhJJ9sc4JIhJDM24daU9" alt=""><figcaption><p>The demo scene has a "Global" Time Scale, plus one for each of the RGB colors.</p></figcaption></figure>

## Add Magic Time Manager to the Scene

Create an empty object and add the [`MagicTimeManager`](/magic-pig-games/magic-time-local-time-scale/magic-time-manager.md) component to it. Add any default TimeScales to this, such as the "Global" one created in the last step.

<figure><img src="/files/LuSwxjV0S2mTmzItb3Ul" alt=""><figcaption><p>Any object can easily hook into the Initial Time Scales attached to <code>MagicTimeManager</code></p></figcaption></figure>

## Set up the Initial Time Scales for your Objects

If you're using the `MagicTimeUser`, or if you'd like to run your own method for this in your own `IHaveLocalTime` class, you'll want to populate the Initial Time Scales for your objects. This can be done on the prefabs themselves.

At runtime, the objects will subscribe to instances of these Time Scales via the Magic Time Manager class. The object will be affected by the Time Scales set here.

<figure><img src="/files/9BFSmkYyhKXxRbxHEAJS" alt=""><figcaption><p>The "Red" sphere in the demo is affected by "Global" and "Red" Time Scale objects.</p></figcaption></figure>

## Implement the Time Value in Your Code

Now that we have everything set up, it's time to ensure your code is properly implementing the Time Scale values. You can get additional scripting information in the documentation pages.

<figure><img src="/files/9kMdwKjfsoRTKksuMv52" alt=""><figcaption></figcaption></figure>

For the demo scene, the `SphereMovement` class controls the movement of the red, green, and blue spheres. There is a `baseSpeed` value which handles the overall default speed.&#x20;

Instead of using `Time.deltaTime` to determine the amount of movement the object should experience each frame, we will use the `sphere.DeltaTime`, which is the modified value based on the TimeScale objects the sphere is being affected by.

`DeltaTime` is a property exposed in [`MagicTimeUser`](/magic-pig-games/magic-time-local-time-scale/magic-time-user.md).

## Optional: Set up Time Zones

In the demo scene, there are two [Time Zone](/magic-pig-games/magic-time-local-time-scale/time-zone.md) spheres -- one will make objects move fast, the other slow. You can create a Time Zone area similar to this by adding an object with a `Collider` on it, with the "Is Trigger" value set `true`.

Then, add the `TimeZone` component to this object, and set the "Time Scale Value" to a value you'd like.

<figure><img src="/files/zweoRE2hRsl4qEflbT9L" alt=""><figcaption></figcaption></figure>

Now, whenever an `IHaveLocalTime` object triggers the zone, the `LocalTime` instance created by the Time Zone object will affect the object. The effect is removed when the object exits the trigger area.

## Optional: Test the Demo

Test the Demo scene for yourself to experience how Magic Time operates. In the demo, colorful balls will fly around an area, passing through time zones that will speed up and slow down their motion.

The demo allows for changing the Local Time of all objects, or all objects of a specific color. Objects affected by multiple Time Zones will have the effects stacked.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://infinitypbr.gitbook.io/magic-pig-games/magic-time-local-time-scale/quick-start.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
