0 votes

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
fixedprocess(true)
RayNode = get
node("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)
in Engine by (21 points)

1 Answer

+2 votes

Vector2(1, 0)
vector2(-1, 0)

mAYbe SoMe UppEr/LoWer CaSe IssUe?

by (177 points)

THANK YOU SO MUCH LOL. IT WAS SERIOUSLY THAT SIMPLE ROFL

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.