Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | ShaneGrey413 | |
Old Version | Published before Godot 3 was released. |
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():
set_fixed_process(true)
RayNode = get_node(“RayCast2D”)
func _fixed_process(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)