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

Making a special Valentine's day game with Unity3D and Playmaker. Dropping gems and Slider UI.

Feb 14, 2021
About this tutorial

Here is a special Valentine's day game (not a complete game build just had a little time to throw a tut together - more of a jam). I'm using Unity and Playmaker and creating a game base of heart gems falling and then collecting and updating a slider to then trigger level complete. ๐Ÿ‘‰๐Ÿผ To Sign up f

Written Guide

This Valentine's project is a complete mini-game in one sitting: a heart bouquet slides along the bottom of the screen catching falling gem hearts, a UI slider fills as you collect, and a level-complete screen pops at 100 percent. Beyond the holiday theme, it's a tidy template for any catch-the-falling-objects game.

Step 1 โ€” Player movement from the Input Manager

On a Movement FSM, a Get Axis action reads the Horizontal axis from Project Settings > Input Manager โ€” which already maps both arrow keys and A/D, a small accessibility win for left-handed players โ€” storing the result in a float called x move every frame. A Set Velocity action then drives the player's X from that variable. The player needs a Rigidbody (gravity off) and a generously wide Box Collider; wider means easier catches, so size it to taste. The default speed felt sluggish, so the axis multiplier got bumped to 3 and eventually 5.

Step 2 โ€” Build the falling gem

The heart model comes from the free Simple Gems Ultimate Animated Customizable Pack on the Asset Store, with a pink material dragged on. Wrap it in an empty named Heart Gem, scale it to about 0.3, and give it a Box Collider with Is Trigger checked, a Rigidbody with gravity on (physics handles the falling), and a tag of gem. Make sure its Z position matches the player's plane โ€” a mismatch here is why early catches silently fail. Save it to a Prefabs folder and delete the scene copy.

Step 3 โ€” Detect catches and score them

A Score manager FSM named Gem Detection runs a Trigger Event on the player: on trigger enter with the gem tag, it fires a detected event. The detected state activates the player's particle burst, does an Int Add of 1 to a current score variable (once, not every frame), then waits 0.5 seconds โ€” matching the particle system's max lifetime โ€” before a follow-up state deactivates the particles and loops back to listening.

Step 4 โ€” Randomized spawner

A Gem Spawner empty (with a temporary small cube so you can see it) gets repositioned before every spawn. The Spawner FSM uses two Random Float actions โ€” X between -2.5 and 2.5, Y between 5 and 6 โ€” defining a box across the top of the screen, then Set Position moves the spawner there. A Create Object action instantiates the heart prefab at the spawner, a random Wait of 0.1 to 0.3 seconds passes, and the loop repeats. Random position plus random interval is what keeps the rain of gems feeling organic.

Step 5 โ€” The slider score and level complete

Add a UI Slider (about 400 x 30, handle deleted since it's a progress bar, not a control). Slider values are normalized from 0 to 1, so each gem adds 0.1 to a slider value float via Float Add โ€” ten gems fills the bar โ€” and UI Slider Set Value pushes the variable into the slider. After each update, a Float Compare checks slider value against 1: equal or greater fires level complete, which activates a pink level-complete canvas (TextMesh Pro, bold, centered) and deactivates the spawner so the hearts stop falling. Otherwise it loops back to detection and the game keeps going.

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 →