error : invalid operants "object" and "Vector2: in operand "=="

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By paczuszki
func _physics_process(delta):
if velocity == Vector2(0,0):
	move()
velocity.y +=10*delta
velocity = move_and_collide(Kappa*delta)

Line that not work is if velocity == Vector2(0,0):

function move

func move():
target=get_global_mouse_position()
height = get_global_mouse_position().y-global_position.y - 32
height = min(height,-32)
velocity =PhysicsHandler.projection(global_position,target,height)

PhysicsHandler

extends Node
class_name PhysicsHandler

static func  projection (starting_position,end_position,height,gravity = 10):
var velocity = Vector2()
var displacement =  end_position - starting_position 

var time_up= sqrt(-2*height / float(gravity))
var time_down= sqrt(2*(displacement.y - height) / float(gravity))

velocity.y = -sqrt(-2*gravity*height)
velocity.x = displacement.x/float(time_up+time_down)

return velocity

Any idea what id dont work ?

:bust_in_silhouette: Reply From: kidscancode

move_and_collide() returns an object: KinematicCollision2D, which you’re assigning to velocity. See https://docs.godotengine.org/en/latest/classes/class_kinematicbody2d.html#class-kinematicbody2d-method-move-and-collide