my charakter falls too fast (2d platformer)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By xAkuma09

my charakter falls too fast (2d platformer):

extends KinematicBody2D

onready var screenshaker = $Camera2D/screenshaker
var move = Vector2()
var speed = 200
var jump_speed = -300

var gravity = 10
var lastdir = 1

func _physics_process(delta):
move.y += gravity
move.x = (Input.get_action_strength(“right”) - Input.get_action_strength(“left”))*speed
if sign(move.x) == 0:
$Sprite.flip_h = lastdir == -1
elif sign(move.x) == -1:
lastdir = -1
$Sprite.flip_h = true
else:
lastdir = 1
$Sprite.flip_h = false
if move.y < 0: $Sprite.play(“jump”)
if move.x != 0: $Sprite.play(“run”)
else: $Sprite.play(“idle”)

   if Input.is_action_pressed("up") and is_on_floor():
	move.y = jump_speed
move_and_slide(move, Vector2.UP)
:bust_in_silhouette: Reply From: timothybrentwood

Changing:

func _physics_process(delta):
    move.y += gravity

to

func _physics_process(delta):
    if is_on_floor():
        move.y = 0
   else:
        move.y += gravity

should work. No need to accumulate gravity if your character is on the floor.