0 votes

well, i dont know why but moveandslide are wrong, anyone can help me?


extends Node2D

const UP = Vector2(0,-1)
const BOOST = 200
const GRAVITY = 10

var motion = Vector2()

func _ready():
pass # Replace with function body.

func physicsprocess(delta):
motion.y += GRAVITY

if Input.is_action_just_pressed("ui_accept"):
    motion.y =-BOOST

    motion = move_and_slide(motion,UP)
Godot version latest
in Engine by (15 points)

1 Answer

+1 vote
Best answer

move_and_slide() is a method of KinematicBody2D. It does not work with Node2D, which your script extends.

More information:

by (21,930 points)
selected by
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.