Hey thanks for the help but im having a hard time implementing that to the code.
extends KinematicBody2D
var candoublejump = 0
var velocity = Vector2(0,0)
const SPEED = 180
const GRAVITY = 30
const JUMPFORCE = -450
const MAXFALLSPEED = 50
const RUNSPEED = 290
const UP = Vector2(0,-1)
func physicsprocess(_delta):
if Input.is_action_pressed("Run"):
if velocity.x > 0:
velocity.x = velocity.x + 60
$Sprite.play("walk")
$Sprite.flip_h = false
if Input.is_action_pressed("Left"):
if Input.is_action_pressed("Right"):
velocity.x = 0
else:
velocity.x = -velocity.x
if velocity.x < 0:
velocity.x = velocity.x - 60
$Sprite.play("walk")
$Sprite.flip_h = true
if Input.is_action_pressed("Right"):
if Input.is_action_pressed("Left"):
velocity.x = 0
else:
velocity.x = -velocity.x
elif Input.is_action_pressed("Right"):
velocity.x = SPEED
$Sprite.play("walk")
$Sprite.flip_h = false
elif Input.is_action_pressed("Left"):
velocity.x = -SPEED
$Sprite.play("walk")
$Sprite.flip_h = true
else:
$Sprite.play("idle")
velocity.y = velocity.y + GRAVITY
if Input.is_action_just_pressed("Jump") and is_on_floor():
velocity.y = JUMPFORCE
can_doublejump = false
if !is_on_floor() and can_doublejump and Input.is_action_just_pressed("Jump"):
velocity.y = JUMPFORCE can_doublejump = true
velocity = move_and_slide(velocity,Vector2.UP)
velocity.x = lerp(velocity.x,0,0.2)
I tried to implement it that way. if you could tell me what I did wrong I would be gratefull.
and thanks for the patience I have zero knowledge about programing.