Skip to main content
โ€น Back to Tutorials
Intermediate Unity

Remake Roller Splat with Unity 3D and Playmaker - Set up Movement and using Raycast to detect wall

Feb 3, 2021
About this tutorial

In this Unity and Playmaker tutorial series I'll recreate Roller Splat. PART 1 - Setting up a movement system and then using Raycast to detect when the ball hits a wall. Absolutely NOCODE. Also check out How to Make a Bounce Game Series https://bit.ly/39HIYBU. ๐Ÿ‘‰๐Ÿผ To Sign up for email updates on

Written Guide

This opening tutorial of the Roller Splat remake builds the game's core mechanic: a ball that rolls in straight lines until it hits a wall. The interesting part is how it stops โ€” not with collision events, but with a raycast that looks ahead of the ball. Here's the full setup in Unity and Playmaker.

Step 1 โ€” Scene and ball setup

Start from a URP project stripped to essentials (keep the post-processing volume), build settings on iOS or Android, camera angled top-down. Create a sphere named Ball, tagged player, scaled to 0.8 โ€” but enlarge its sphere collider to about 0.65 radius and check Is Trigger. Shrinking the mesh while growing the collider leaves a visual gap between ball and walls, room for effects later. Give it a bright red material with red emission, kill the scene fog in the Lighting tab, and set the camera background to solid yellow instead of the skybox (walls will be white). ProGrids โ€” installable as a preview package โ€” snaps everything to the one-unit grid, which matters because the whole game is built from one-meter wall cubes.

Step 2 โ€” Detect input

FSMs live on a Managers > Movement empty rather than on the ball itself. The detect input state holds four Get Key Down actions (up, down, left, right arrows), each sending its own event โ€” named swipe up, swipe down, swipe left, swipe right, since the desktop keys are stand-ins for the mobile swipe gestures that will replace them. Worth knowing for the directions: in this top-down view, away from the camera is +Z, toward it is -Z, left is -X, right is +X.

Step 3 โ€” Two speed variables, four move states

Create two floats on the FSM: speed plus (7) and speed minus (-7). Every direction state reuses one of these, so tuning the game's speed later means editing two numbers instead of digging through four states. Each swipe state runs a Translate on the ball (specify the game object โ€” the owner is the manager, not the ball) along the correct axis with the correct sign, per second and every frame, so the ball keeps moving as long as the state is active. The Debug toggle in Playmaker shows live variable values if you need to verify.

Step 4 โ€” Stop with a raycast

Alongside each Translate, add a Raycast from the ball's center pointing in the direction of travel โ€” direction vector of 1 or -1 on the matching axis โ€” with a distance of 0.5. That number is deliberate: the ray starts at the ball's center and the ball is one unit wide, so half a unit reaches exactly to its surface. When the ray touches anything, a hit event fires the stop ball transition into a state that contains nothing at all โ€” and that's the trick. No Translate running means no movement; an empty state is the brake. A FINISHED transition sends it straight back to detect input for the next swipe.

Step 5 โ€” Walls and testing

Walls are plain one-meter cubes, tagged wall, with trigger box colliders, snapped to the grid. Scatter a few, hit play, and the ball zips between them, stopping flush against each wall it approaches. With movement and detection proven, the next tutorial starts building out real levels.

Unity tools by Bliz Studio
Built for our own games — now on the Asset Store

Multi Tag — unlimited hierarchical tags for any GameObject. Hierarchy Pro — style your whole hierarchy with rules. Made by a Unity dev, for Unity devs.

Explore our Unity assets →