# Time Fracture: Getting Started This tutorial goes from a clean Unity project to a working time-controlled scene, built by hand. You'll make one object that can rewind, freeze, loop, skip and remix its Timeline, then a second object on its own Timeline, then a player interaction that changes how events play out. **Time:** about 45 minutes · **Unity:** 6000.3 (Unity 6.3) · **Works in:** 2D or 3D projects Next notes: [[TimeFracture-Tutorial-Wiring]] → [[TimeFracture-Tutorial-Enemies]] · Reference: [[TimeFracture-Scripts]] · Ideas: [[TimeFracture-Design-Ideas]] --- ## Step 0: Set up the project ### 0.1 Check the packages Open **Window ▸ Package Manager ▸ In Project** and confirm both of these are listed. Install any that are missing from the **Unity Registry**: - **Timeline** (`com.unity.timeline`) - **Input System** (`com.unity.inputsystem`) Unity 6 templates normally include both. ### 0.2 Use the Input System only 1. Open **Edit ▸ Project Settings ▸ Player ▸ Other Settings ▸ Configuration**. 2. Set **Active Input Handling** to **Input System Package (New)**. 3. Let Unity restart. Time Fracture never uses the old Input Manager. ### 0.3 Import Time Fracture Use either method: - **.unitypackage**: go to **Assets ▸ Import Package ▸ Custom Package…**, choose `TimeFracture.unitypackage`, then click **Import**. - **.zip**: unzip it so that `Assets/TimeFracture/` sits inside your project's `Assets` folder, then switch back to Unity. ### 0.4 Check the import - The **Console** should show no red errors. If it does, see *Troubleshooting* at the end. - The menu bar should have **Tools ▸ Time Fracture** with three items: *Build Demo Scene*, *Build Tutorial Scene (2D)* and *Build Enemy Rewind Demo (2D)*. > [!tip] Want to see it before building it? > Run **Tools ▸ Time Fracture ▸ Build Demo Scene** and press Play. Three objects run on three Timelines at once. > > Use the on-screen HUD: > - **Tab** selects an object. > - **R** reverses, **F** freezes and **Space** pauses. > - **← / →** skip, and **↑ / ↓** change speed. > - **L** loops, **B** breaks the loop and **G** rewinds everything. > > Then come back here and build one yourself. --- ## Step 1: Your first Time Channel ### 1.1 Make an object 1. Create a new scene with **File ▸ New Scene ▸ Basic 2D** (or Basic 3D). 2. Add an object to animate: - **2D:** **GameObject ▸ 2D Object ▸ Sprites ▸ Square**. Name it `Mover`. - **3D:** **GameObject ▸ 3D Object ▸ Cube**. Name it `Mover`. ### 1.2 Give it a Timeline 1. Open **Window ▸ Sequencing ▸ Timeline** and dock the window somewhere you can see it. 2. Select `Mover`. In the Timeline window, click **Create**. 3. Save the asset as `Mover.playable`. Unity adds a **PlayableDirector** to `Mover` and creates an **Animation Track** bound to it, adding an Animator if needed. ### 1.3 Animate it 1. On the Animation Track, click the red **record** button. 2. With the playhead at **0:00**, set the object's position to **x = -4**. 3. Move the playhead to **4:00** (4 seconds) and set **x = 4**. 4. Move the playhead to **8:00** and set **x = -4** again. 5. Click record again to stop. The Timeline is now 8 seconds long. > [!warning] Recorded clips and position offsets > If the object jumps toward the scene origin when you play, select the clip on the Animation Track and untick **Remove Start Offset**. Also make sure the track's offset setting is **Apply Transform Offsets**. That makes your keys absolute positions. ### 1.4 Add the Time Channel 1. Select `Mover` and click **Add Component ▸ Time Fracture ▸ Time Channel**. 2. In the Time Channel, set: - **Channel Id:** `Mover` - **Groups:** leave the list as `World` - **Play On Start:** ✔ - **End Behaviour:** `Loop` The Time Channel switches the PlayableDirector to **Manual** mode and moves the playhead itself. You don't need to change anything on the director. ### 1.5 Add the debug HUD 1. Create an empty object called `Time Tools` and add **Time Fracture ▸ Time Debug HUD**. 2. Press **Play**. The square slides back and forth. Try each control: | Key | What happens | Feature | |---|---|---| | R | Plays backwards | Reverse | | ↑ / ↓ | Faster or slower; keep pressing ↓ past 0 to rewind | Rate | | F | Freezes in place (press again to resume) | Freeze | | Space | Pauses | Pause | | ← / → | Jumps back or forward 1 second | Skip | | G | Rewinds the whole world, then G again to restore | World scale | ### 1.6 Use the play-mode inspector While still in Play mode, select `Mover`. The Time Channel inspector now has a **Runtime** panel: - A **Scrub** slider. Drag it to move time by hand. - **Pause, Reverse, Freeze** and **Restart** buttons. - **Skip** and **Set Rate**. Try a rate of `-0.5` for slow rewind. - **Loop Current**, **Break Loop** and **Clear Loop**. --- ## Step 2: Segments, the chapters of your Timeline Segments are named slices of time. Loops, jumps and remixes all use them. 1. Stop Play mode. In the Timeline window, show the **Markers** lane if it's hidden. The Timeline window's toolbar has a toggle for it. 2. Right-click in the Markers lane at **0:00** and choose **Add ▸ Time Fracture ▸ Segment Start**. Select the marker, and in the Inspector set **Segment Name** to `Out`. 3. Add another **Segment Start** at **4:00** and name it `Back`. A segment runs from its marker to the next Segment Start, or to the end of the Timeline. So `Out` covers 0–4 s and `Back` covers 4–8 s. To check, select `Mover` and click **Log segments & markers found in timeline** in the Time Channel inspector. The Console lists both segments. Press **Play**, select `Mover`, and look at the **Segments** rows in the Runtime panel: - **Jump** moves straight to that segment. - **Play** plays just that segment, then stops on its last frame. - **Reverse** plays it backwards. - **Loop** repeats it until you click **Break Loop**. > [!note] Segments without markers > You can also type segments into the Time Channel's **Segments** list, giving each a name, a start and an end. If a list entry and a marker share a name, the list entry wins. --- ## Step 3: Remix the order (playlists) A playlist plays segments in any order, each forward or backward, at its own speed, any number of times. 1. Stop Play mode. On the Time Channel, open **Playlists** and click **+**: - **Name:** `Remix` - **Loop Playlist:** ✔ 2. Under **Steps**, add three entries: | Segment | Reverse | Speed | Repeats | Hold After | |---|---|---|---|---| | Back | ✘ | 1 | 0 | 0 | | Out | ✔ | 2 | 1 | 0 | | Back | ✘ | 0.5 | 0 | 1 | 3. Set **Start Playlist** to `Remix` and press **Play**. The object plays *Back*, then *Out* backwards twice at double speed, then *Back* in slow motion, holds for 1 second, and starts over. 4. While it runs, use the inspector's **Shuffle** and **Flip** buttons. Hold **G** (world rewind) too: a playlist rewinds step by step. Clear **Start Playlist** before moving on. --- ## Step 4: Events on the Timeline (Time Event markers) A Time Event marker fires when the playhead crosses it, in whichever direction you choose. It can also run commands. 1. In the Markers lane at **2:00**, add **Add ▸ Time Fracture ▸ Time Event**. In the Inspector set: - **Event Id:** `Halfway` - **Fire When:** `Both` 2. Listen for it without code. On `Mover`'s Time Channel, under **Unity Events ▸ On Time Event (String)**, click **+**. Drag in any object that has an **Audio Source** (with a short clip assigned) and choose **AudioSource ▸ Play ()**. A Particle System with **ParticleSystem ▸ Play ()** also works. 3. Press Play and rewind with R. The event fires both ways. To listen from code instead: ```csharp using TimeFracture; using UnityEngine; public class EventLogger : MonoBehaviour { void OnEnable() => TimeWorld.AnyEvent += Log; void OnDisable() => TimeWorld.AnyEvent -= Log; void Log(TimeEventInfo e) => Debug.Log(e); // "Mover:Halfway @ 2.00s (forward)" } ``` > [!note] Signals work too > Unity's own **Signal Emitters** fire through the channel, to the SignalReceiver on the bound object. By default they fire only when time runs forward; turn on **Signals Fire In Reverse** on the channel to change that. Timeline doesn't fire signals by itself in Manual mode, which is why the channel does it. --- ## Step 5: A second Timeline and groups 1. Make a second object, `Spinner`, give it its own Timeline (`Spinner.playable`), and animate its rotation Z from 0 to −360 over 3 s. 2. Add a **Time Channel**: - **Channel Id:** `Spinner` - **Groups:** `World` and `Clocks` - **End Behaviour:** `Loop` 3. Press Play. Both objects run at the same time on separate Timelines. In the HUD, **Tab** switches between them, so you can freeze one and rewind the other. Groups let one command affect many channels at once. Each channel's speed is: ``` effective rate = channel rate × each group's scale × world scale ``` Add a temporary script to try it: ```csharp using TimeFracture; using UnityEngine; using UnityEngine.InputSystem; public class GroupTest : MonoBehaviour { void Update() { if (Keyboard.current.cKey.wasPressedThisFrame) TimeWorld.SetGroupScale("Clocks", -1f, 2f); // ease every clock into rewind if (Keyboard.current.vKey.wasPressedThisFrame) TimeWorld.SetGroupScale("Clocks", 1f, 2f); } } ``` > [!tip] One Timeline, many objects > To animate several objects together, put them under one parent with one PlayableDirector, one Timeline (one track per child) and one Time Channel. See section 3 of [[TimeFracture-Tutorial-Wiring]]. --- ## Step 6: Player interaction changes the outcome Here, a trigger zone freezes the clocks, and a flag changes what happens when `Mover` reaches 6 s. ### 6.1 A zone that freezes a group 1. Create an empty object called `Freeze Zone`. Add a **Box Collider 2D** (or Box Collider), tick **Is Trigger**, and size it. 2. Add **Time Fracture ▸ Time Command Trigger**: - **When:** `OnTriggerEnter2D` (or `OnTriggerEnter` in 3D) - **Required Tag:** `Player` - **Commands:** click **+**. Set **Action** to `FreezeFor`, **Target** to `Group`, **Group Name** to `Clocks`, and **Seconds** to `3`. 3. Add a player that can enter the zone. The quickest option is a Square tagged `Player`, with a Rigidbody2D, a BoxCollider2D, and **Time Fracture ▸ Examples ▸ Time Demo Player 2D**. That gives you A/D to move and Space to jump. ### 6.2 A branch that depends on a flag 1. Add a second trigger zone called `Paradox Switch`, with a **Time Command Trigger** whose command is **Action** `SetFlag`, **Flag** `Paradox`. 2. In `Mover`'s Timeline, add a **Time Event** at **6:00**: - **Event Id:** `Branch` - **Fire When:** `ForwardOnly` - **Commands:** - `JumpToSegment` → Target `Self`, Segment `Out`, **Only If Flag** `Paradox` *is true* - `ClearFlag` → Flag `Paradox` 3. Press Play. Normally `Mover` runs its full route. If the player touches `Paradox Switch` first, `Mover` is thrown back to `Out` when it reaches 6 s. The player's choice has changed how events play out. Flags appear in the HUD's **flags** row. --- ## Step 7: Where to go next | Want to… | Read | |---|---| | Change an object's time by touching, shooting or blocking it; colour-code Timelines; build lenses that reveal hidden Timelines; record the player and cooperate with echoes | [[TimeFracture-Tutorial-Wiring]] (plus **Build Tutorial Scene (2D)**) | | Make AI enemies, bullets and physics props rewind, so fights can be undone | [[TimeFracture-Tutorial-Enemies]] (plus **Build Enemy Rewind Demo (2D)**) | | Look up what each script and field does | [[TimeFracture-Scripts]] and `README.md` | | Get level and game ideas | [[TimeFracture-Design-Ideas]] | --- ## Troubleshooting | Problem | Fix | |---|---| | Errors mentioning `UnityEngine.InputSystem` | Install the **Input System** package (Step 0.1). | | Errors mentioning `UnityEngine.Timeline` or `Playables` | Install the **Timeline** package. | | Keys do nothing; Console warns about the Input Manager | Set **Active Input Handling** to *Input System Package (New)* (Step 0.2). | | The object doesn't move when you press Play | The PlayableDirector needs a Timeline asset, and the Time Channel needs **Play On Start** ticked. Check that the Console shows no errors. | | The object jumps to the scene origin | Untick **Remove Start Offset** on the clip, and set the track to *Apply Transform Offsets* (Step 1.3). | | Segments or markers aren't found | Use **Log segments & markers found in timeline** in the Time Channel inspector. Markers on **muted** tracks are ignored. | | An event fires twice, or not on a jump | Jumps don't fire the markers they pass over unless you turn on **Fire Events On Jump**. Markers exactly at the spot you land on still fire. | | No sound from Audio Tracks | Expected: audio doesn't play in Manual mode. Trigger sounds from Time Events instead. | | Debug HUD keys clash with your controls | Untick **Keyboard Controls** on the HUD. | > [!note] Version notes > This package was written for Unity 6000.3, with the Timeline and Input System package versions that ship with it. The code was compiled against stand-in versions of the Unity APIs and its time logic was simulated outside Unity, but it hasn't been run in the editor itself. If something doesn't compile on your version, the error message and line number are usually enough to fix it quickly.