![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Azrael451208 |
Hey I’m new to game development and coding and I’ve been following this tutorial on YouTube
and I have an error in my code but I cant figure out what the problem is
thanks in advance for the help
The code
extends KinematicBody2D
const UP = Vector2(0,-1)
const GRAVITY = 20
const MAXFALLSPEED = 200
const MAXSPEED = 80
const JUMPFORCE = 300
var motion = Vector2()
func _ready():
pass
func _physics_process(_delta):
motion.y += GRAVITY
if motion.y > MAXFALLSPEED:
motion.y = MAXFALLSPEED
if input.is_action_pressed("right"): **Error here**
motion.x = MAXSPEED
elif input.is_action_pressed("left"):
motion.x = -MAXSPEED
else:
motion.x = 0
if is_on_floor():
if input.is_action_just_pressed("space"):
motion.y = -JUMPFORCE
motion = move_and_slide(motion,UP)