Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | IVTheSimple |
So I just started learning how to code and decided to use a tutorial to help me get started, but even though I copied the code almost 1-1 with few exceptions that would only be cosmetic changes not actual changes to the code, I’m getting an error when trying to use “if”
this is my code
extends KinematicBody2D
var curHp: int = 40
var maxHp: int = 60
var moveSpeed : int = 250
var damage : int = 10
var cash : int = 30
var curLevel : int = 0
var curXP : int = 0
var xpToNextLevel : int = 50
var xpToLevelIncreaseRate : float = 1.2
var interactDist : int = 70
var vel : Vector2 = Vector2()
var facingDir : Vector2 = Vector2 ()
onready var rayCast = get_node(“RayCast2D”)
func _physics_process (delta):
vel = Vector2()
# inputs
if Input. is_action_pressed(“move_up”):
vel.y-=1
facingDir = Vector2(0, -1)
if Input. is_action_pressed(“move_down”):
vel.y-=1
facingDir = Vector2(0, 1)
if Input. is_action_pressed(“move_left”):
vel.x-=1
facingDir = Vector2(-1, 0)
if Input. is_action_pressed(“move_right”):
vel.y+=1
facingDir = Vector2(1, 0)
vel = vel.normalized()
move the player
move_and_slide(vel * moveSpeed)