0 votes

I'm in the process of learning how to use Kinematic Body to make a character controller. However I'm having some issues with implementing gravity, for some reason it compounds up to a certain point, but only when receiving movement input. Here's the entire physicsprocess function:

func _physics_process(delta):
movement_input = Vector2(
    lerp(movement_input.x, 
    Input.get_action_strength("move_right") - 
    Input.get_action_strength("move_left"),
    0.4),
    lerp(movement_input.y,
    Input.get_action_strength("move_down") - 
    Input.get_action_strength("move_up"),
    0.4))

movement_input.x = clamp(movement_input.x, -1, 1)
movement_input.y = clamp(movement_input.y, -1, 1)

var gravityNormal = ProjectSettings.get_setting("physics/3d/default_gravity_vector")
var gravityStep = (gravityNormal * ProjectSettings.get_setting("physics/3d/default_gravity")) * delta
velocity += gravityStep

var max_speed_change = max_acceleration * delta
var desired_velocity = (Vector3(movement_input.x, 0, movement_input.y) * max_speed)

velocity.x = desired_velocity.x
velocity.z = desired_velocity.z

velocity = move_and_slide(velocity, Vector3.UP, true, 4, deg2rad(max_ground_angle))

Gravity doesn't seem to compound when standing still for some reason.

Godot version v3.4
in Engine by (16 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.