0 votes

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=moveandslide(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"))

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:
elif extra_jumping:
    if jumps_made<=maximum_jumps:
elif falling:
Godot version Windows 3.5.1
related to an answer for: Invalid type in function move_and_collide
in Engine by (12 points)

1 Answer

+1 vote

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...

by (16,664 points)
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.