Skip to main content
‹ Back to Tutorials
Intermediate Unity

Unity + Playmaker - EASY Pinball Game - Setting up Ball

Feb 27, 2022
About this tutorial

In this mini Unity + Playmaker tutorial series, we will be taking a look at creating an EASY Pinball Game. In this first tutorial of the series, I will show the steps to setting up ball and the board background. ► Download the board graphics here: https://bit.ly/3BWk0v2 (to Join my discord server

Written Guide

This opening tutorial of the pinball series sets up the foundation: importing and slicing the board art, building the table with edge colliders, and creating a physics ball that spawns and launches up the chute on click. It's mostly groundwork that the bumpers, scoring, and flippers in later parts build on.

Import and slice the sprite sheet

The art is made in Adobe XD (any tool works) mostly in white so it can be tinted inside Unity. Import the sheet and set its Texture Type to Sprite (2D and UI), change Sprite Mode to Multiple, and set Max Size to 2048 (a power of two), then Apply. If the Sprite Editor errors, install the 2D Sprite package from Package Manager. In the editor, Slice auto-cuts well-separated sprites; name each piece, then Apply and Close to get individual, compression-friendly sprites.

Build the board and its colliders

Set the camera background to a solid purple instead of the skybox. Create an empty Pinball Board at 0,0,0 and add the board gradient sprite. Add an Edge Collider 2D and use Edit to trace points around the outer edge, then bump the Edge Radius to about 0.05 for a little cushion. Add a second Edge Collider for the inner edge the same way. Drop in the board outline sprite, tint it hot pink (the payoff of white art — it can flash or animate on hits), and set its Order in Layer to 1 so it sits above the gradient.

Create the ball prefab

Add the ball sprite, set its Order in Layer high (around 10) and scale it down (about 0.25). Add a Circle Collider 2D and a Rigidbody 2D, leaving defaults except Collision Detection, which should be Continuous so the fast-bouncing ball never tunnels through a collider between frames. Add and assign a pinball ball tag, then drag the ball into a prefabs folder to make it a prefab and delete it from the scene since it'll be spawned at runtime.

Mark the start and end points

Inside the board, add an empty Ball Start positioned at the launch corner. Add an empty Ball End near the drain with a Box Collider 2D set to Is Trigger, and give it a ball end tag — that trigger is how later parts will detect a lost ball. These anchors define where balls appear and where the game-over check happens.

Spawn and launch the ball

On a game manager, add a ball start FSM with a Wait For Start state that uses Get Mouse Button Down (left) to fire a start ball event. In the Start Ball state, Create Object the ball prefab at the Ball Start spawn point and use Store Object to remember it as ball. Then Add Force 2D on that stored ball as an Impulse on the Y axis — around 20 launches it cleanly up the chute. Leaving out the loop-back transition limits play to one ball; adding a finished transition back to Wait For Start enables a chaotic multi-ball mode.

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 →