This is Part 1 of a 5-part series on making your first game with no code using Visual Scripting in Unity. By the end of this tutorial, you'll have a scene with player movement and a camera that follows your player.
1 Prerequisites
Before starting, make sure you have:
- Unity 2021 or later - Visual Scripting is built into Unity 2021+. If you're using an older version, you'll need to import the Bolt package separately.
- Basic familiarity with the Unity interface
2 Creating a New Project
Start a new 3D project in Unity Hub:
- Open Unity Hub and click New Project
- Select 3D as the template
- Name your project (e.g., "The Cube")
- Click Create
3 Setting Up the Scene
Creating the Ground
- In the Hierarchy, right-click and select 3D Object → Cube
- Rename it to "Ground"
- In the Inspector, find the Transform component
- Set the Scale to: X: 15, Y: 1, Z: 1000
Creating the Player
- Add another Cube: 3D Object → Cube
- Rename it to "Player"
- Move it above the ground using the Y-axis arrow (or set Y position to 1)
Adding Color to the Player
- In the Project window, right-click in Assets
- Select Create → Material
- Name it "Player Material"
- Click the color swatch and choose red
- Drag the material onto your Player object
4 Adding Physics
To make the player fall with gravity:
- Select the Player object
- Click Add Component in the Inspector
- Search for and add Rigidbody
Press Play to test - your player should now fall onto the ground!
5 Creating an Obstacle
- Select the Player and press Ctrl+D to duplicate
- Rename the duplicate to "Obstacle"
- Move it forward (positive Z direction)
- Create a new material with a light gray color
- Apply it to the Obstacle
6 Visual Scripting Setup
Now let's add movement using Visual Scripting:
- Select the Player
- Click Add Component → Script Machine
- For Source, select Graph
- Click New and name it "Player Graph"
- Click Edit Graph
The graph comes with two events: Start (runs once when the game begins) and Update (runs every frame). For physics, we'll use Fixed Update instead.
7 Adding Forward Movement
- Right-click in the graph and search for "Fixed Update" - add it
- Search for "Rigidbody Set Velocity" - add it
- Connect Fixed Update's output to Set Velocity's input
- For the velocity, we need to create a Vector3:
- Search for "Create Vector3"
- Set Z to 20 (forward speed)
Fixing Gravity
Setting velocity directly resets gravity. To fix this:
- Add "Rigidbody Get Velocity"
- Add "Vector3 Get Y"
- Connect the Y value to your Create Vector3's Y input
8 Preventing Rolling
Your player might roll due to friction. To fix this:
- Right-click in Assets → Create → Physic Material
- Name it "No Friction"
- Set Dynamic Friction to 0
- Set Static Friction to 0
- Set Friction Combine to Minimum
- Drag it to the Player's Box Collider Material slot
9 Adding Side-to-Side Movement
- In the graph, add "Input Get Axis"
- Set the axis name to "Horizontal"
- Add a Multiply node, multiply by 10
- Connect the result to the X value of your Vector3
Now you can use A/D or arrow keys to move side to side!
10 Using Variables
Let's make the speeds adjustable from the Inspector:
- In the graph, go to the Object variables tab
- Add a Float variable named "Forward Speed" with value 20
- Add a Float variable named "Side Speed" with value 10
- Drag these variables into the graph and connect them instead of hard-coded values
11 Camera Follow with Cinemachine
- Go to Window → Package Manager
- Select Unity Registry
- Search for Cinemachine and Install
- In Hierarchy: Cinemachine → 2D Camera
- Drag the Player to the Follow field
- Adjust the camera rotation and distance as needed
Changing the Background
- Select the Main Camera
- Change Clear Flags from Skybox to Solid Color
- Choose your preferred background color
What's Next?
In Part 2, we'll cover:
- Detecting collisions with obstacles
- Restarting the level when you lose
- Creating a finish line
- Collectible coins with saved variables
Next: E02 - Gameplay Loop
Learn to create win/lose conditions and collectibles