For a character to jump, you need three things: it must fall (gravity), a floor to land on, and a button that pushes it upwards, only when it is standing on something.
You need:
- a character named player (a Square or an Image);
- a floor: a wide, flat Square named floor, at the bottom of the scene;
- a button named btnJump (a Button or a Square), at the bottom right of the screen.
Step 1: give the character gravity
- Select player.
- In the inspector, tap the ⚙ Object behavior button.
- Choose Falls and bounces: the object falls with gravity.
👉 In the same window, Gravity changes how fast it falls: Light to fall gently, Strong to fall fast. Even simpler: Platform character walks and jumps by itself, with no nodes at all (Behaviors guide).
Step 2: add a solid floor
- Select floor.
- Tap ⚙ Object behavior and choose Ground / wall: it doesn't move and stops objects that fall on it.
- Put player a little above the floor.
👉 You can make platforms the same way: squares set to Ground / wall placed higher up.
Step 3: the jump button
- Open the scene's Blueprint.
- Add the “On Object Click” event and choose btnJump as its target.
- Add the “If on ground” node (category Logic & Conditions) and choose player as its target.
- Add the “Impulse (jump)” node (category Movements & AI): target player, Vertical force (negative = up) = -15.
- Link the output of “On Object Click” to the input of “If on ground”, then the True output of “If on ground” to the input of “Impulse (jump)”.
- Save, then start the game and tap the button.
On Object Clicktarget: btnJump
→
If on groundtarget: player
True →
Impulse (jump)target: player · -15
👉 Why “If on ground”? Without it, the player could jump again in mid-air and fly away by tapping the button several times.
👉 Negative = upwards. In Yop2D, Y numbers grow towards the bottom of the screen. -15 makes a small jump, -20 a big one.
What about moving while jumping?
Add the left and right buttons from the guide Move a character (method 1). You can keep one finger on “right” and tap “jump” with another finger.
If it doesn't work
- The character doesn't fall: check that it is set to Falls and bounces (⚙ Object behavior button).
- It goes through the ground: the ground must be set to Ground / wall.
- Nothing happens when you tap: check that the wires are linked, and that the output used is True. Remember to save before starting the game.
- To compare, open the “Platform” example game that comes with Yop2D: it uses exactly this setup.