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.