0 votes

I want to get whatever speed I had right before I hit a wall. What i'm doing right now is
if is_on_wall():
if my_speed.x < 100:
do this
do that
But i get "34" or "-34".
enter image description here

in Engine by (17 points)

AFAIK KinematicBody2D doesn't have a speed of its own because you are supposed to handle that yourself... so it's up to you to have that speed, isn't it? Otherwise how did you move your object in the first place? Maybe there is a bug or misunderstanding in your own code?

I am moving it with moveandslide(), i'm giving it a Vector2() value on the x whenever i press "a" or "d" and then using moveandslide(), i just want to get whatever that number was right before i hit a wall, the only way i can think of it is using isonwall() but by that point the Vector2().x gets set to 0 because i want it to stop.

Please log in or register to answer this question.

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 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 webmaster@godotengine.org with your username.