Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | art cat |
HERES MY CODE PLZ HELP ME
extends KinematicBody2D
const SPEED = 400
const JUMP = -400
const GRAVITY = 20
const UP = Vector2(0, -1)
var motion = Vector2()
func _physics_process(delta):
motion.y += GRAVITY
if Input.is_action_pressed("RIGHT"):
$AnimatedSprite.flip_h = false
$AnimatedSprite.play("WALK")
motion.x = SPEED
elif Input.is_action_pressed("LEFT"):
$AnimatedSprite.flip_h = true
$AnimatedSprite.play("WALK")
motion.x = -SPEED
else:
motion.x = 0
$AnimatedSprite.play("IDLE")
if is_on_floor():
if Input.is_action_just_pressed("JUMP"):
motion.y = JUMP
else:
$AnimatedSprite.play("JUMP")
motion = move_and_slide(motion, UP)