Before, making a character walk, jump and climb took a lot of nodes and formulas. Now you simply choose what the object does in the inspector's ⚙ Object behavior window, and the engine does the rest.
- a character named player (an Image);
- a ground: an Image or a wide, flat Square at the bottom of the scene;
- a ladder (an Image), if you want to climb;
- a Joystick at the bottom left of the screen.
Step 1: the ground
- Select the ground.
- In the inspector, tap the ⚙ Object behavior button.
- Choose Ground / wall: it doesn't move, you walk on it and bump into it.
Step 2: the character
- Select player and tap ⚙ Object behavior.
- Choose Platform character.
- In "Its settings", leave Controls: Joystick. You can choose the Speed and the Jump height.
- Add a Joystick to the scene. No need to choose a target: the character follows it by itself.
- Run the game: the joystick makes the character walk, and pushing it up makes it jump.
Step 3: the ladders
- Select the ladder and tap ⚙ Object behavior.
- Leave Scenery and check A ladder in the "It is also…" part.
- Make the ladder go a little above the platform it leads to.
- Run the game: in front of the ladder, push the joystick up to climb and down to go down. At the top, the character lands on the platform.
Step 4: the animations, by themselves
In the Animations window, give the character's animations these names: idle, walk, jump, climb and duck. The engine plays the right animation for what the character does, and flips the image when it goes left.
- An animation is missing? No problem: the image just doesn't change in that case.
- Several characters? Start the name with the object's name: player_walk, enemy_walk. Each one takes its own.
- You can also choose the animation by hand: in "Animations played automatically", tap a line and pick from the list (with a thumbnail of each animation).
An enemy that walks by itself
In ⚙ Object behavior, choose Patrol (back and forth): the enemy walks on its own one way, then the other. It turns around at the edge of its ground (it doesn't fall into the void) and against a wall. It keeps gravity, and its walking animation follows its movements.
Set its Speed and Its picture faces (left or right): the library enemies face left. To make it defeat the player, follow the engine's "A patrolling enemy" mission (☰ → Step-by-step missions).
A top-down character (or iso view)
- Choose Top-down character in ⚙ Object behavior.
- In Directions, choose 4 (up, down, left, right), Iso view (4 diagonals) or Left / right.
- Name the animations with the direction: walk_up, walk_down, walk_left, walk_right, and idle_up… (in iso view: walk_ne, walk_nw, walk_se, walk_sw).
Change behavior during the game
The “Change the behavior” node offers the same choices as the window. Example: a crate set to Ground / wall starts falling when a lever is pulled: “Change the behavior” → Falls and bounces. Every setting left on "(don't change)" keeps its value.
To see the result
Download the Climb & run (platform, ladders, animations) and Dungeon walk (iso view) examples in the Examples tab of Yop2D's home screen, then tap the hero and open ⚙ Object behavior.
If it doesn't work
- The character doesn't move: check Controls: Joystick (not "None") and that there is a joystick in the scene (or in the HUD).
- It falls through the ground: the ground must be set to Ground / wall.
- It doesn't climb: the ladder must have A ladder checked, and the character Can climb ladders: yes.
- The animation doesn't change: check the animation names, or pick them by hand in the list.