Skip to main content
‹ Back to Tutorials
Beginner Unity

Super Easy - Duck and Jump Movement using Unity with Playmaker - Beginner Game Dev Tutorial #Shorts

Jul 9, 2021
About this tutorial

Super Easy FREE tutorial on creating a simple Duck and Jump type runner game using Unity 3D and Playmaker for beginning game devs. Also check out How to Make a Bounce Game Series https://bit.ly/39HIYBU. #Shorts ► Download Playmaker at https://bit.ly/3dV8JzC ► Download Unity at https://unity.com �

Written Guide

A compact endless-runner style duck and jump game built in Unity with PlayMaker, broken down FSM by FSM. There are only a handful of moving parts here: the level scrolls toward the player, the player crouches or jumps, and a collision ends the run. That's enough for a complete game loop.

Scroll the level, not the player

The level holds the ground and the enemies, and it is the level that moves. A Translate action drives it along negative Z at a value of 3, pulling the environment toward the player continuously.

This is the standard runner trick and it's worth understanding why it's used. Keeping the player at a fixed position means your camera never has to chase anything, your collisions all happen in the same region of space, and difficulty is a single number you can tune, which is the translate speed.

Jump on key release

The player FSM handles two actions, jump and crouch, and it does that by detecting key down and key up rather than just polling a key. The default state plays the run animation.

When the player hits key up, the FSM sets a velocity of 5 on the character and plays the jump animation. Firing on key up rather than key down is a small choice with a real feel consequence, since it makes the jump resolve on release.

Land by watching velocity

Once the jump animation is playing, the FSM checks the character's velocity. If the Y velocity is 0, the character has stopped moving vertically, which means it has landed, and the FSM transitions back to the run animation.

Reading velocity to detect landing avoids needing a ground collider check or a raycast for this simple case. It's fewer moving parts, and in a runner where the ground is flat and continuous, it holds up fine.

Crouch while held

Crouching works on the opposite input pattern. If the player holds down the down key, the FSM moves to the crouch state and plays the down animation. While it's there, it is also detecting whether the key has been released.

As soon as the player lets the key go, the FSM sends the character back to the running animation. Hold to crouch and release to stand is the behavior players expect, and building it as a held state rather than a toggle keeps it from getting out of sync.

End the run on a hit

A separate PlayMaker FSM handles enemy detection. Any time the player hits an enemy, it plays the death animation and sets the speed of the level to 0.

Setting the level speed to zero is the whole fail state. The scroll stops, the world freezes, and the death animation reads clearly because nothing else is moving. Keeping the collision logic in its own FSM rather than tangled into the movement FSM also means you can extend it later, adding lives or a restart, without touching the jump and crouch logic at all.

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 →