Invalid type in function move_and_collide

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By nini

the message “Invalid type in function ‘move_and_collide’ in base ‘KinematicBody2D (Player.gd)’. Cannot convert argument 1 from int to Vector2” keeps showing up every time I try to run the program, I’m beginner at Godot so I don’t know what’s wrong or how to solve it?

It’s hard to tell you exactly what’s causing the error if you don’t share the code that’s causing it. Please include what you’ve tried to do.

kidscancode | 2020-11-20 16:29

:bust_in_silhouette: Reply From: jgodfrey

From the error, you’ve supplied an integer value as the first argument to move_and_collide. Looking at the docs here:

https://docs.godotengine.org/en/stable/classes/class_kinematicbody2d.html#class-kinematicbody2d-method-move-and-collide

The first argument is supposed to be a Vector2 which represents the motion vector.

So, you need to stop providing an int and instead provide a Vector2.

If you can’t make that work, then as noted above, we’ll need to see some code.