Here is the error I am getting: Invalid call. Nonexistent function 'vector2' in base 'KinematicBody2D (KinematicBody2D.gd)'.
Why can't I use vector2 with my KinematicBody2D that makes no sense to me. Can someone answer this and let me know an alternative to making this script that will work or tell me what I did wrong?
Here is my script
extends KinematicBody2D
export var motion_speed = 140
var RayNode
func ready():
setfixedprocess(true)
RayNode = getnode("RayCast2D")
func fixedprocess(delta):
var motion = vector2()
if (Input.is_action_pressed("ui_up")):
motion += Vector2(0, -1)
if (Input.is_action_pressed("ui_down")):
motion += Vector2(0, 1)
if (Input.is_action_pressed("ui_right")):
motion += Vector2(1, 0)
RayNode.set_rotd(-90)
if (Input.is_action_pressed("ui_left")):
motion += vector2(-1, 0)
RayNode.set_rotd(90)
motion = motion.normalized()*motion_speed*delta
move (motion)