Attention | Topic was automatically imported from the old Question2Answer platform. | |
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)