Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Oni |
Hello!
As the title says, I’m trying to code a jump that feels like the character is accelerating at the start, like a propulsion jet BUT with a pre determined height. I’m using Metroid Prime as reference:
It’s hard to notice on video but there is some sort of acceleration right after she starts jumping
Usually for a regular jump in fps you can simply set the velocity.y to the desired strength and then subtract it with gravity
func jump():
velocity.y = strength
func _physics_process(delta):
velocity.y -= gravity * _delta
move_and_slide()
Later I’ve found a method to use a defined height to determine the strength of the jump:
func jump():
velocity += sqrt(jump_height * 2 * gravity) * Vector3.UP
So if I set jump_height to 2 for example, the character will jump 2 meters
Now I’m trying to do the same thing but using a linear acceleration, like you are using a jetpack to jump 2 meters, so you gain the desired velocity over a short period of time. You don’t need to hold the jump button thought, just press it once.
How can I achieve this? How can I make my character jump accelerating to the desired velocity over a really short period of time to give this impression of weight/propulsion, but still constrain the jump to the defined height?
Thank you!