Why is the move_and_slide interpreting a vector2 as an integer?

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

I have a vector defined as export var velocity:=Vector2(0.0,0.0)
after putting the code through things to get the Kinematicbody2d I try and use velocity=move_and_slide(velocity,UP_DIRECTION) and it says it’s an integer.

const UP_DIRECTION:=600
export var speed=100.0
export var jump_str=100.0
export var maximum_jumps=100.0
export var extra_jump_str=100.0
export var gravity=100.0
export var jumps_made:=0
export var velocity=Vector2()


func physicsprocess(delta: float) -> void:
var horizontal_direction=(Input.getactionstrength("ui.right")-Input.getactionstrength("ui.left"))
velocity.x=horizontal_direction*speed
velocity.y+=gravity*delta

var falling=velocity.y>0.0 and is_on_floor()
var jumping=Input.is_action_just_pressed("ui.select") and is_on_floor()
var extra_jumping=Input.is_action_just_pressed("ui.select") and falling
var jump_canceled=Input.is_action_just_released("ui.select") and velocity.y<0
var idling= is_on_floor() and is_zero_approx(velocity.x)
var running= is_on_floor() and not is_zero_approx(velocity.x)

if jumping:
	jumps_made+=1
	velocity=-jump_str
elif extra_jumping:
	jumps_made+=1
	if jumps_made<=maximum_jumps:
		velocity.y+=-extra_jump_str
elif falling:
	velocity.y=0.0
velocity.normalized()
move_and_slide(velocity,UP_DIRECTION)
:bust_in_silhouette: Reply From: jgodfrey

I assume the error is being caused by your second argument to move_and_slide() (UP_DIRECTION). In your code, that IS an integer, but also needs to be a Vector2. You probably want Vector2.UP in that second arg…