# Gravity speed is uneven when there's input (KinematicBody 3D)

Attention Topic was automatically imported from the old Question2Answer platform.

Hello, I recently implemented easing so i can smooth out the movement of my character. All and all everything is working well, except for when my character is falling. Basically, the speed of the fall is increased when the player moves mid-air. I have no idea how to balance it out with my current code. Any advice is greatly appreciated. Here is the relevant code:

``````const MAX_SPEED = 25
const LOOK_AROUND_SPEED = 0.2
const GRAVITY_ACCELERATION = 30

var input_move: = Vector3()
var gravity_local: = Vector3()
var snap_vector: = Vector3()
var velocity = Vector3.ZERO
export(int) var jump_speed: = 10

disable_movement = false

func _physics_process(delta):
input_move = _get_directions()

if input_move != Vector3.ZERO:
velocity = input_move * MAX_SPEED

if is_on_ceiling():
gravity_local = Vector3.ZERO

snap_vector = Vector3.DOWN

if not is_on_floor():
gravity_local += Vector3.DOWN * GRAVITY_ACCELERATION * delta
else:
gravity_local = Vector3.ZERO

if is_on_floor():
snap_vector = -get_floor_normal()

if (Input.is_action_just_pressed("jump") and is_on_floor() and !isGrapplingActive) or isGrappleHit:
#when player collides with an enemy -> jump
if isGrappleHit:
jump_speed *= 2
snap_vector = Vector3.ZERO
gravity_local = Vector3.UP * jump_speed
isGrappleHit = false
jump_speed = 10

# SHOOT GRAPPLE
# basically a method which targets an enemy node and flies towards it.
if Input.is_action_just_pressed("grapple"):
if !isGrapplingActive:
grapple_target()

if isGrapplingActive:
update_grappling()
else:
velocity = move_and_slide_with_snap(velocity + gravity_local , snap_vector, Vector3.UP)
if shotgun_velocity == Vector3.ZERO:
disable_movement = false
var ease_curve = -0.1
if not is_on_floor():
ease_curve = -0.5
var slowdown = ease(min(delta/0.4, 1.0), ease_curve)
velocity -= move_and_slide_with_snap((velocity * slowdown) + gravity_local, snap_vector, Vector3.UP)
print(velocity)
else:
velocity = Vector3.ZERO
#velocity -= velocity * slowdown

func _get_directions() -> Vector3:
var z: float = ( Input.get_action_strength("backward") - Input.get_action_strength("forward") )
var x: float = ( Input.get_action_strength("right") - Input.get_action_strength("left") )
if isGrapplingActive or disable_movement:
x = 0
z = 0
return transform.basis.xform(Vector3(x, 0, z)).normalized()

``````

Ok, seems I fixed the problem. I simply changed the line for the velocity by only changing the x and z axis. Basically went from:

``````if input_move != Vector3.ZERO:
velocity = input_move * MAX_SPEED
``````

To this:

``````if input_move != Vector3.ZERO:
velocity.x = input_move.x * MAX_SPEED
velocity.z = input_move.z * MAX_SPEED
``````

And it seems to be fine. the y axis is only affected by the gravity_local variable.