Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | tjhosek |
I’m having some trouble properly implementing gravity for a KinematicBody node. Here’s what I have so far
# code that gets direction from input
velocity = velocity.linear_interpolate(direction * speed, acceleration_amount * delta)
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y += jump_power
velocity.y -= gravity * delta
velocity = move_and_slide(velocity, Vector3.UP)
Whenever the character is falling, the y velocity is capped at about 4 times the value of gravity. Is this some side effect of the move_and_slide() method or is there something here I’m not getting? For reference I’m mostly following Code with Tom’s fps guide on youtube. So far I’ve tried tweaking the values of the jump_power, gravity, and the speed and acceleration amount values in the linear_interpolation but that hasn’t affected this cap. I’m using default values for the physics setting of the project, though I don’t know if that would affect a KinematicBody.