Skip to content
Bit Quirky Round Trip
Visual Scripting

Search documentation

All topics and APIs

Close returns focus to Search.

What are you looking for?

Try a common topic or a C# feature.

Browse the reference instead

Esc closes · Tab reaches results · Enter opens the focused link

v1.0.0
Menu

Lifecycle puts the moments Unity runs your script at the top of the left rail: setting up an object, updating it each frame, or reacting when something touches it. Start here to find what makes an object act, without searching through all its other methods.

New to scripts? A method is a named task, with its own canvas. Unity knows certain method names, such as Start, Update, and OnTriggerEnter2D, and calls them at the matching moment. These are Unity’s event functions, also called callbacks or messages. Round Trip groups them under Lifecycle.

When you open an unfamiliar script, the most important methods to find first are usually its setup and per-frame work, along with its reactions to game events. Round Trip lifts these out of the general Methods list into Lifecycle, above it, so you do not have to hunt through helper methods to find the starting points.

Left-rail section The question it answers Platformer examples
Lifecycle When does this script react? Awake sets the player up; OnTriggerEnter2D reacts to entering a coin’s area.
Methods What work can something ask this script to do? CollectCoin collects a coin; RespawnAtStart sends the player home.

Lifecycle methods are still methods in the same C# class. The separate section changes where you find them, not how they run. Recognized callbacks already in your script appear here automatically, rather than being duplicated under Methods. Click one to read or edit its canvas just like any other method.

A method under Methods needs a caller: another method, another script, or an event connected in Unity’s Inspector. Those Inspector connections are another way into a script, so begin with Lifecycle and follow the calls from there.

Unity’s own documentation is the authority on what each callback means and when it fires. Start with its introduction to event functions; the Messages list in the MonoBehaviour scripting reference names every callback a script can receive, each linked to its own page. Each callback name in Pick the moment links to its page there too.

See why Lifecycle and Methods are separate

Select a screenshot to enlarge it.

The Methods section of the PlayerController rail, with CollectCoin highlighted and RespawnAtStart farther down.
Figure 1. Find the work those moments can call The rail continues below Lifecycle. CollectCoin and RespawnAtStart stay under Methods with the other named tasks. The two sections organize one script.
Full PlayerController window showing Lifecycle above Methods, CollectCoin selected, its diagram in the middle and method details on the right.
Figure 2. Open a method in the same canvas CollectCoin is selected here. Opening a Lifecycle row uses this same canvas and right rail; it does not switch to another editor or move code out of the class.

Choose the moment that matches what you want to happen. These common callbacks cover everyday behaviors in the Platformer sample. The names in the middle column are the rows to pick in Add lifecycle method.

When should it happen? Pick In the Platformer sample
Once, as the object appears. Use it to find the object’s own parts and remember starting values. Awake PlayerController finds the player’s body and collider, and remembers where the player started.
Once, before the enabled component’s first frame update. Use it for setup that needs other scene objects’ Awake work to be finished. Start Build it visually starts from a component that uses it to announce a coin when you press Play.
Every frame, many times a second. Use it to read keys or check rules and change what the player sees. Update PlayerController respawns a player who falls below the level. After the level is finished, Door restarts it when Return is pressed. Your first class uses it to move a square with the arrow keys.
On the steady physics clock, 50 times a second unless the project changes it. Use it to move anything that has a Rigidbody 2D or Rigidbody. FixedUpdate PlayerMotor moves and jumps the player. EnemyPatrol walks the enemy and turns it at the edges of its patrol.
When something enters an area it can pass through, such as a coin, a door, a checkpoint or your spike. OnTriggerEnter2D PlayerController collects the coin it touched. Door finishes the level when the player stands in its doorway.
When two solid objects bump into each other. OnCollisionEnter2D PlayerController stomps an enemy it lands on, and sends the player back to the start when they walk into one. PlayerMotor notes when the player is standing on the ground.
Every time the component is disabled or its object is switched off; also during destruction. OnDisable EnemyPatrol stops a defeated enemy from sliding.

A few more you will meet:

  • OnEnable runs when the component is enabled on an active object; LateUpdate runs each frame after Update, useful for a camera following a moving player.
  • OnTriggerStay2D and OnTriggerExit2D react while something stays in a trigger area and when it leaves. OnCollisionStay2D and OnCollisionExit2D do the same for solid contact.
  • OnDestroy handles cleanup when a previously active object is destroyed. Reset runs in the editor when you first add the component or use its Reset command; EnemyPatrol uses it to set a short patrol around where you place the enemy.

The picker groups callbacks under CORE, PHYSICS, FRAME, APP, INIT, and LOAD, and adds INPUT sections for player controls. Search by name when you already know the event you want.

When the player presses a button, Unity’s Input System can call a method named On plus the control’s name: OnJump, OnMove, OnAttack. A Player Input component set to Send Messages makes those calls, using the actions in your project’s actions file. The picker reads them and lists them in three sections:

  • INPUT · PLAYER and INPUT · UI: one row for each action in those maps of the actions file, such as OnMove and OnNavigate. Picking one writes On…(InputValue value) with a first line that reads the value: a press check for a button, value.Get<Vector2>() for a direction, value.Get<float>() for an amount.
  • INPUT · DEVICES: OnDeviceLost, OnDeviceRegained and OnControlsChanged, which the Player Input sends when a gamepad is unplugged, plugged back in, or the player switches between keyboard and gamepad.
  • New player control… opens a window that adds a new action with common keys and gamepad buttons, puts a Player Input on the player, saves the scene and writes the method in one step. Round Trip never points the Player Input at your project-wide actions file (Unity warns against that): it copies that file once to Assets/PlayerControls.inputactions, uses the copy for this and every later control, and leaves the original untouched. Without the Input System package, the row opens Package Manager instead.

Your first class walks through the whole thing with a Jump button.

A name that ends in 2D belongs to Unity’s 2D physics: Rigidbody 2D, Box Collider 2D, Circle Collider 2D and the other 2D colliders. The same name without 2D belongs to 3D physics: Rigidbody, Box Collider, Sphere Collider. They never mix. The Platformer is a 2D game, so your spike needed OnTriggerEnter2D; plain OnTriggerEnter would never have run.

Both need a collider on each object, and at least one of the two objects needs a rigidbody. The player has one.

  • A trigger is an area other objects pass through. Tick Is Trigger on the collider, and Unity raises the OnTrigger moments. Coins, doors, checkpoints and danger zones are triggers. Unity’s trigger collider setup covers the details.
  • A collision is between two solid objects that push against each other. Leave Is Trigger unticked, and Unity raises the OnCollision moments. Floors and walls are solid, and so are enemies you can stand on.

Which pairs of colliders raise which moments depends on the kinds involved; Unity’s interaction between collider types has the full table.

For a component on an active object, the usual starting sequence is Awake, OnEnable, then Start before its first update. Start runs once; OnEnable runs again when the component is enabled again.

While the component is enabled, Update and LateUpdate run each frame. FixedUpdate follows a separate physics clock: there can be zero, one, or several physics ticks in a rendered frame. Switching a component off calls OnDisable, not OnDestroy; destruction is a separate event.

The rail and picker use a configured order to make callbacks easy to scan. Their list order does not schedule your game, or guarantee which object’s callback runs first. Unity controls execution; see its event function execution order for the full rules.

Open PlayerController and add a Lifecycle method

  1. Open the class's rail

    Open Tools > Round Trip > Graph view. Choose your class with the class name at the top left, or press Cmd/Ctrl+O.

    Clip: the Unity editor's Tools menu opens, the Round Trip submenu opens, and Graph view is clicked; each of those menu entries is highlighted in turn with an arrow pointing at it, and the Round Trip graphs window opens.
    PlayerController's rail with the class name and the + beside Lifecycle highlighted: Lifecycle lists Awake, Update, OnCollisionEnter2D and OnTriggerEnter2D above Methods.
  2. Filter and pick the moment

    To open an existing callback, click its row under Lifecycle. To add one, press + on that section, type part of its name in Type to filter, then select it in Add lifecycle method.

    The add lifecycle method picker for PlayerController, filtered to lateupdate, with the Type to filter box and the LateUpdate() row under CORE highlighted.
  3. Build and compile its canvas

    Add the work to its canvas, or call one of your named Methods from it. Press Compile to save the canvas changes.

    PlayerController's rail after LateUpdate was added, with the Compile button highlighted: Lifecycle now lists five rows, LateUpdate selected, its magenta entry node with exec and self pins on the canvas.

Compare the two ways to add a method

Select a screenshot to enlarge it.

The Add lifecycle method picker for PlayerController lists OnEnable, Reset, Start, FixedUpdate, LateUpdate, OnDisable and OnDestroy under CORE.
Figure 3. Lifecycle +: choose a Unity event This existing PlayerController example shows the picker contents. Start is under CORE. Already implemented callbacks are omitted; the footer reports four implemented and fifteen hidden for this class.
The New method window for PlayerController has an editable name, void return type and an empty parameters list.
Figure 4. A named task has different controls This is the New method dialog, rather than the lifecycle picker. Use a named method for work such as CollectCoin; choose a recognized event from Lifecycle + when Unity should call it at a particular moment.

You need the Platformer sample installed and its folder indexed, with the Platformer scene open.

Build the spike's GameObject

  1. Create the spike object

    Choose GameObject > Create Empty, then press Add Component, type Sprite Renderer and add it. In the Inspector, rename the object Spike.

    Clip: the Unity editor's GameObject menu opens and Create Empty is clicked; the menu title and the Create Empty entry are highlighted in turn with arrows pointing at them, and a new GameObject appears in the Hierarchy.
    Inspector for the new Spike GameObject with the name box and the Add Component button highlighted: an unassigned Sprite Renderer with its Install 2D Sprite Package banner.
  2. Position and color it

    Under Transform, set Position to 5, 0.75, 0 and Scale to 1, 0.5, 1. Under Sprite Renderer, set Color to red.

    Same Inspector with the highlighted Transform Position (5, 0.75, 0), Transform Scale (1, 0.5, 1) and Sprite Renderer Color (red).
  3. Add a trigger collider

    Press Add Component, type Box Collider 2D and add it. Tick Is Trigger.

    Same Inspector after adding a Box Collider 2D, with the Is Trigger tick and the Add Component button highlighted.

Create and attach the Spike script

  1. Select the folder

    In the Project window, select the sample’s Platformer/Runtime folder.

    Project window with Assets/Platformer/Runtime selected and the Runtime folder highlighted.
  2. Open New Class

    Choose Assets > Round Trip > New class. A small window titled New class opens.

    Clip: with the Runtime folder selected in the Project window, the Assets menu opens, the Round Trip submenu opens and New class is clicked; the Assets title, the Round Trip entry and the New class entry are highlighted in turn with arrows pointing at them, and the New class window opens.
  3. Fill it out and create

    Under NAME, type Spike. Leave LOCATION as it is: Runtime, class, public. Under PARENT CLASS, click the MonoBehaviour card. Press create.

    The new class window for Assets/Platformer/Runtime with the NAME box, the MonoBehaviour card and the create button highlighted: NAME reads Spike, LOCATION Runtime/class/public, PARENT CLASS MonoBehaviour selected, ready to create.
  4. Attach the script

    Select the Spike object in the scene, press Add Component, type Spike and add it.

    Inspector for Spike after Add Component attached the real compiled Spike script, with the Add Component button and the Spike (Script) component highlighted.

Add OnTriggerEnter2D to Spike

  1. Pick the class

    Open Tools > Round Trip > Graph view. Click the class name at the top left of the window (or press Cmd/Ctrl+O) and pick Spike. The left rail then shows an empty Lifecycle section.

    Clip: the Tools menu, the Round Trip submenu and Graph view are highlighted in turn as the Round Trip graphs window opens.
    Spike selected in the Round Trip window with the class name highlighted and an arrow pointing at it; its Lifecycle section reads List is empty.
  2. Filter and add the event

    Press + on the Lifecycle header. The Add lifecycle method list opens with the cursor in Type to filter. Type trigger, then pick OnTriggerEnter2D(Collider2D) under PHYSICS: press Enter or click it.

    Spike's rail with the + beside Lifecycle highlighted and an arrow pointing at it; the Lifecycle section reads List is empty.
    The add lifecycle method picker for Spike filtered to trigger, with the Type to filter box and the OnTriggerEnter2D(Collider2D) row under PHYSICS highlighted.
    Spike's rail after OnTriggerEnter2D was added, with its new Lifecycle row highlighted: its magenta entry node with exec, self and other pins is on the canvas.

Recognize the completed callback's canvas

Select a screenshot to enlarge it.

Spike has OnTriggerEnter2D selected under Lifecycle. Its three-node diagram and Collider2D other input are visible.
Figure 5. Know where the event and input appear The next section builds this completed first-stage visual script. A newly added callback starts empty. OnTriggerEnter2D lives under Lifecycle. The Inputs section and entry node both show other.
Spike method details show private void OnTriggerEnter2D(Collider2D other), Static false and an Inputs row for other.
Figure 6. Match the event to its input A close-up of the completed Spike window: the right rail shows an ordinary C# method signature. Collider2D other is the thing that entered the trigger, ready to use on the canvas.

The player already knows how to go back to the start: its PlayerController script has a method called RespawnAtStart. The spike only needs to ask whatever touched it for its PlayerController, and call that.

Send the player back to the start

  1. Drag from the other pin

    Press on the other pin and drag onto empty canvas to its right, then let go. In the menu that opens, find GetComponent<T>() under Methods and click it.

    Spike's canvas with the entry node's other pin highlighted and an arrow pointing at it, the pin to drag onto empty canvas.
    Dragging the entry node's other pin onto empty canvas opens a member menu there; GetComponent<T>() is picked under methods.
  2. Choose PlayerController

    A chooser titled GetComponent<T> asks which part of the object you want. Type PlayerController into Type name and pick RoundTrip.Platformer.Runtime.PlayerController under YOUR PROJECT.

    GetComponent<T>'s type chooser filtered to PlayerController, with the Type name box and the PlayerController row under YOUR PROJECT 1 highlighted.
  3. Drag to RespawnAtStart

    Press on that result pin and drag onto empty canvas to the right. In the menu that opens, type Respawn and, under Methods, click RespawnAtStart().

    Dragging GetComponent's result pin onto empty canvas opens a member menu there; RespawnAtStart() is picked under methods, landing wired to both the result and GetComponent's exec.
    The whole window with the wired three-node diagram: OnTriggerEnter2D, GetComponent and RespawnAtStart joined by one white exec wire and two purple value wires.
  4. Compile

    Press Compile in the toolbar.

    Spike's whole window with the three-node draft pending: the lit Compile button in the toolbar and the Compile button in the Previewing your changes panel are highlighted, with arrows pointing at them.
    The same window right after a real Compile: the canvas comes back showing the same three nodes, the Previewing your changes panel is gone and the toolbar Compile button is grey.
  5. Press Play and walk right

    Press Play and walk right. The moment you touch the spike, the player is back at the start.

    The whole Unity editor in Play mode: the Play button at the top center is lit and highlighted with an arrow pointing at it, the Hierarchy lists the Spike object, and the Game view shows the player standing back at the start position after being respawned off the spike.

Read the entry node and the two calls

Select a screenshot to enlarge it.

Close-up of OnTriggerEnter2D: white exec starts the work and purple other carries the collider; self is the gray pin between them.
Figure 7. Start at the event and the thing that touched exec starts the work. other is the Collider2D that entered the trigger. Its purple wire carries that object into the first call; the wires continue beyond this close-up.
Close-up of GetComponent feeding PlayerController into the target of RespawnAtStart while the white wire connects their exec pins.
Figure 8. Follow the calls and their targets GetComponent uses the incoming collider as its target. Its PlayerController result becomes the target of RespawnAtStart. The white exec wire says to make the calls in that order.

Right now the spike assumes that whatever touches it is the player. In the sample only the player can reach that spot, so it works. If an enemy or a falling object could touch the spike, it would have no PlayerController to respawn, and the game would log an error. The sample’s own scripts always check first, and you can add the same check with a branch:

Check for a player before respawning

  1. Break the old link

    Right-click the wire between GetComponent and RespawnAtStart and choose Break link.

    Right-clicking the wire between GetComponent and RespawnAtStart opens a small wire menu with a single Break link row, highlighted with an arrow pointing at it.
  2. Add a branch

    Drag from the GetComponent node’s right Exec pin onto empty canvas. In the All actions menu, pick branch under FLOW CONTROL. A yellow BRANCH node lands, unwired; drag the same Exec pin to its Exec pin.

    Dragging GetComponent's exec pin onto empty canvas opens the all actions menu; branch is picked under FLOW CONTROL, then wired from the same exec pin.
  3. Check for null

    Right-click empty canvas below the branch, type equals, and pick the Equals row with the = icon, not a method row with the ƒ call mark. If it lands on top of another node, drag it clear by its title. Wire the GetComponent result pin into its Left pin, click the small box beside Right, type null and press Enter. Wire its Result into the branch’s Condition.

    Equals is placed from the all actions menu, wired from GetComponent's result on the left with a typed null literal on the right, and its result wired into the branch's condition.
  4. Exit when missing

    Drag from the branch’s true pin onto empty canvas and pick return under FLOW CONTROL. A magenta EXIT node lands; wire true into its Exec.

    Dragging the branch's true pin onto empty canvas opens the statement menu; return is picked under FLOW CONTROL, landing a magenta EXIT node wired to true.
  5. Wire the safe path and compile

    Wire the branch’s false pin into the RespawnAtStart node’s Exec. Press Compile.

    Clip of the whole window: dragging the branch's false pin into RespawnAtStart's exec wires the safe route, then the pointer goes to the Compile button in the toolbar, which is highlighted with an arrow pointing at it, and presses it.

Read the safe spike after Compile

Select a screenshot to enlarge it.

The compiled safe Spike visual script checks GetComponent against null, branches to EXIT on true and reaches RespawnAtStart on false.
Figure 9. See the complete saved result All three screenshots show the same compiled diagram at different scales. The extra check lets the event ignore anything without a PlayerController.
EQUALS compares the player lookup with a visible null literal and sends its red result wire into the BRANCH condition.
Figure 10. Read the question before choosing a route EQUALS asks whether the player part is missing. Its red result fills condition. True means there is no PlayerController, so the spike must leave without calling RespawnAtStart.
BRANCH true curves up to EXIT; false runs through GetComponent to RespawnAtStart, with an other pill feeding the lookup.
Figure 11. Follow both outcomes The true route ends at EXIT. The false route finds the player part again and calls RespawnAtStart. The small other pill carries the same collider supplied by the lifecycle event.

A useful way to organize a behavior is to separate the moment from the work:

  1. Name the moment. “When the player touches the spike” is OnTriggerEnter2D on the spike.
  2. Name what should happen. Often it is a method that already exists, like RespawnAtStart. When it is something new, give it a method of its own under Methods with a name that says what it does, built on its own canvas; New class and method shows how.
  3. Connect them on the moment’s canvas: check what happened if you need to, then call the method.

Keeping the work in named methods keeps each lifecycle canvas short, so it reads as “when this happens, do that”. Anyone who opens the class later sees every moment it reacts to under Lifecycle and what it does at each one by name. Call a neighbor builds the sample’s coin pickup this way.

  • The picker offers only the moments the class does not have yet, and once every one is added it says Every lifecycle method is implemented. The INPUT · PLAYER and INPUT · UI rows appear once a saved scene or prefab has a Player Input set to Send Messages or Broadcast Messages.
  • An On…(InputValue value) method that no saved Player Input calls shows a warning, … is never called: no PlayerInput beside this class sends messages for a “…” action. Unity calls these methods by name and says nothing when the name does not match, so a renamed action would otherwise leave the method silently unused.
  • A class placed on objects that have no collider or rigidbody does not get the touch moments offered, and the picker’s footer counts the hidden rows. A class that is not on any object yet, like Spike before you added it, is offered everything. Rows that cannot be added stay grayed out with the reason beside them.
  • A lifecycle method’s name is locked. Hover it at the top of the right rail and the tooltip explains why: Unity finds the method by that exact name.
  • Same C# runtime: your MonoBehaviour messages remain ordinary C# declarations. Round Trip does not replace Unity’s event dispatch or move the method bodies to another script.
  • Recognition checks the method’s shape: the project catalog matches the name and accepted signature. An On prefix alone does not make a method a lifecycle callback. Project Settings > Round Trip contains Lifecycle recognition, shared by the team.
  • Use the two add controls deliberately: Lifecycle + chooses a recognized callback; Methods + creates a task you name yourself. Adding a callback writes the empty declaration immediately; editing its body waits for Compile.

If you also work in C#, this is the whole of Spike.cs after the three-node version. Picking the moment wrote the empty method straight away; the nodes went in when you pressed Compile.

When it goes wrong

SymptomCheckFix
Nothing happens when the player touches the spikeSelect the Spike object. Does it have a Box Collider 2D with Is Trigger ticked, and the Spike component? Is the method named OnTriggerEnter2D, with the 2D?Add what is missing. A solid collider raises OnCollision moments instead; a 3D moment never runs in a 2D game.
Something you built never runsLook where it is listed in the left rail. A method under Methods runs only when something calls it.Open the moment it should run at under Lifecycle, or add it with +, and call your method from there.
The Console shows a red error naming NullReferenceException when something touches the spikeSomething without a PlayerController entered the trigger.Add the check from Make it safe.
GetComponent is not in the menuDid you drag from the other pin? The menu lists what the thing that touched can do. A right-click on empty canvas opens a different menu.Drag from the other pin onto empty canvas, then look under methods.
Movement looks jittery or ignores wallsSee whether something with a rigidbody is moved in Update.Move it in FixedUpdate, and keep reading keys in Update.
The moment you want is not in the listRead the list's footer for a hidden count, or its message if it is empty.Add the matching collider or rigidbody to the object this class is on and press + again. If every moment is already added, there is nothing to add.
F2 does not rename the methodHover the name at the top of the right rail for the lock message.Keep Unity's name. Use the + on Methods for a method you name yourself.
Full-size image