Survivor type game with jumping.

Godot Version

4.6 stable

Question

I’m trying to make a survivors type game with jumping and I can not figure out how to make the jumping work. I got it to move me up but no way to simulate gravity as I had to turn gravity off in order to get the same effect as vampire survivors movement. Not even sure if this is possible.

Hmmm :thinking: :thinking:… it’s difficult to get…

A common approach is to separate vertical movement from standard gravity. Instead of enabling gravity, manually adjust the player’s y-position over time and detect collisions to prevent falling through the floor. This allows smoother, arcade-style jumping.

To do this in 2D, you’d have to use separate variables for the horizontal and vertical position and velocity. Horizontal velocity depends on the 4 directional movement inputs and affects only the horizontal position. Vertical velocity depends on the jump button and gravity and affects only the vertical position. The vertical position needs a maximum value (probably 0.0) for ground height.
Then you can get the final position.y by adding the vertical position and the horizontal position.y .

That said, the next question would be which parts of the player should be affected by its vertical position. Maybe it would be enough to only move its sprite (and disable its hurtbox instead of moving it along).
If you want proper hit detection while the player is jumping, you should change it to 3D.

If you really want to do this, I recommend making a 2.5D game. Use a Node3D for your environment, and Sprite3D for your characters. You’ll still have to fake the jump, but it will solve a lot of physics collision issues you’ll have if you do this in 2D.

I saw a video on a game jam game that faked jumping in 2D by only moving the sprite up. The player had a shadow, and the shadow was the true position of the player, and the shadow never changed height. Depending on what you want the jumping mechanic to do, you could try that.

3 Likes

Thank you guys for the input. While I was waiting for this post to be approved I sort of fixed the jumping issue. I ended up just using the same type of method to push the character up to push it back down and just made a timer so it stops moving when the timer ends. Have tested this and it stops on the same pixel 30 times in a row

That being said I have serious doubts this is the best way to do this. I’m trying to make a volleyball game with movement like vampire survivors I might just have to start over in 3D. I’ve just never used 3D yet and seems like a lot more work. I may be wrong about that

It would be more work, but not a lot more work.

2 Likes