Skip to main content
Version: Next (dev)

Your First Script

Build a working visual script from nothing in about fifteen minutes. No programming experience needed.

By the end you will have an object that prints a message when the game starts and slowly spins, and you will have used every part of the editor you need for real work.

Before you start

You need a project open in the editor with a scene you can add objects to. If you have not got that far, see Building for Windows and Running a Scene.

1. Create the script asset

In the asset browser, right-click a folder and create a new Visual Script Class asset. Name it something like SpinningThing.

Double-click it to open the script editor. You will see an empty graph on the left and a properties panel on the right.

2. Check the base class

Click on empty space in the graph so that nothing is selected. The properties panel now shows the script's own settings.

Make sure Base Class is set to Component. That means this script behaves like a component you can attach to an object — which is what we want. The other option, StateMachineState, is for state machines.

3. Add an entry point

Right-click in the graph to open the node palette, and type OnSimulationStarted. Add OnSimulationStarted.

This node is an entry point — it runs once when the game starts. You can tell because it has an execution pin (the grey arrow) on its right side only, with nothing on the left.

4. Print something

Right-click again and add Info.

Now connect them: drag from the grey arrow on the right of OnSimulationStarted to the grey arrow on the left of Info. This is an execution connection — it says "when this happens, do that next".

Select the Info node and, in its properties, set the Text to Hello from my first script.

5. Try it

Save the script, then:

  1. Add an object to your scene — a cube will do.
  2. With it selected, add a Script Component to it.
  3. Set that component's Script Class to the asset you just made.
  4. Run the scene.

Your message appears in the log. If it does not, check Troubleshooting.

tip

Placing the object is not enough on its own — OnSimulationStarted only fires when the game actually simulates. If nothing happens, make sure you pressed play rather than just looking at the viewport.

6. Make it move

Now for something that runs continuously. Add a Update node — a second entry point, which runs every frame.

To rotate the object we need three things: the object, its current rotation, and a new rotation to apply.

  1. Add GetScriptOwner. This gives you the game object the script is attached to.
  2. Add GetGlobalRotation, and connect GetScriptOwner's GameObject output to its input.
  3. Add MakeFromAxisAndAngle (in the Quat folder). In its properties set the Axis to (0, 0, 1) — that is straight up — and the Angle to something small like 2.
  4. Add SetGlobalRotation.

Connect the execution pin from Update to SetGlobalRotation, and wire the rotation you built into its input.

Run the scene again. The object turns.

Why it spins at different speeds on different machines

Update runs once per frame, so a faster machine rotates it further each second. Real movement code multiplies by the DeltaTime output of the Update node, which is how long the last frame took. Try wiring DeltaTime through a Multiply into your angle.

7. Make it adjustable

Hard-coding the speed means every object using this script spins identically. Let us expose it.

  1. Deselect everything so the script properties appear.
  2. Add a variable called speed, of type Float.
  3. Tick Expose.
  4. Add a GetVariable node to the graph, set its Name to speed, and use its output for the angle instead of the constant.

Save, and look at the script component on your object. speed now appears there as a setting. Every object using this script can spin at a different rate, with no change to the script.

That is the single most useful thing visual scripting does — see the jump pad recipe for the same idea applied to a real mechanic.

What you have learned

  • Entry points start execution — OnSimulationStarted once, Update every frame.
  • Execution pins (grey arrows) control order; data pins (round) carry values.
  • Nodes without execution pins are read on demand whenever a value is needed.
  • Exposed variables turn one script into a reusable component.

Where next