# Build an isometric 3D game in 2D — #4 Fall and jump

This is part 4 of the 2d/3d(game/engine) conversion used in my puzzle game: Ladder Box, which is available on Steam:

You can find all the textures, scripts in this GitHub repo: https://github.com/fengjiongmax/3D_iso_in_2D

Godot 3.2.x is used in this project, you can check the commits for what’s new in each part of this series.

# Jump state

When a movable has a block at its same height in its moving direction, that movable will switch to the jump state.

Of course, before actually make the jump, the block needs to know if the way of jumping is clear or not, we write such function in movable.gd:

What’s in this function:

• check if movable.game_pos.y +1 is empty or not
• check if the game position after jump and move is clear or not.

Now we can check if the block can jump at the end of the set_next_target function in the move.gd:

There are also scenarios when an unmovable is right next to a movable, so from idle to jump is necessary, so in idle.gd, modify the _command function:

Then in our jump.gd, let’s write something that stores the move direction, and print something when movable enters jump state:

And in our main.gd, to test the code we’ve written:

Then run the project, you can see the output by hitting ‘Z or ‘X’.

## Actual jump movement

Like in the move state, we will have a set_next_target function and some variables.

• and call the set_next_target function at the end of the _enter function

note we did not use the direction passed from the last state to calculate engine_direction, but we need to store this because the jump state always goes up, and when movable exits jump state, it can go back to move state, then we will need move_direction.

Then in the _update function, we will move the movable, bit by bit like in the move state:

And run the scene and hit ‘Z’, then you can see this:

the movable floats after it moves past the unmovable.

# Fall state

Just like move and jump state, there will be a set_next_target and all those variables:

And we can copy the _enter function from the jump state and paste it in fall.gd, and modify a little bit in the _update function:

Then run the scene and hit ‘Z’:

run the scene hit ‘X’:

That’s it, we have the basics for the jump and fall.

Till now, we don’t have many movables or complicated unmovable structures on our board like in Ladder Box, you can try to add more movables and see what happens.

In the next part, we will test the code with different board designs and improve our codes, stay tuned!

You can check out the Github repo for the code committed.

im404.me