Height in Godot2D

kaijikaiji Posts: 1Member


I want to create something in Godot 2D that looks like the top view but behaves like the side view. It is necessary that it works in godot 2D only. I hope someone has an easy answer to that. I kinda couldn't figure it out.
I also want for example the black cube to be able to jump and land on the red block. Thank you in advance.

Answers

  • NeoDNeoD Posts: 181Member
    edited December 2017

    You can tag your grounds objects using groups, or CanvasItem "z" property maybe, and disable collisions of the upper ground, using set_trigger(true) as instance, while your player is jumping.

    edit: error fix

  • SolarLuneSolarLune Posts: 37Member
    edited December 2017

    Basically, you'd have to do this programmatically, as I don't think there's anything built into Godot to give a perception of depth (in physical space) when your view is constricted to 2D. Fundamentally, when you think of "jumping", you're talking about pressing a button when the player is on the ground and applying a force that pushes him upwards. Over time, gravity pushes the player down in the other direction, until he starts falling. Once he hits the ground, he is free to jump again.

    You'd need to do this, basically, but in code. You'd have a "height" variable that designates how "high up" gravity-enabled objects are, and an "upward velocity" variable that designates the movement speed on the depth axis (the one the camera's looking down). Blocks / ground objects can also have "height" variables that tell you what height you'd have to reach to be able to jump on top of them. If the player has the same height as the ground and he's got a jumping velocity less than or equal to 0, then he's standing on it. If the player's trying to jump onto a block but doesn't have a high enough "height", then he can't stand on it / move into it.

  • SomnivoreSomnivore Posts: 102Member

    Why does it necessarily need to work in Godot 2D only?

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file