0 votes

This might be vague to ask but, does anybody know how to make a 2D kinematic body stick to the wall and move in a direction depending if the wall/floor is Horizontal, Vertical, or Angled; similar to how the the SpiderBall Ability or the Geemer Mechanics work?

I can only think of two possible pseudo-code theories on how this works...

[Ideal/effective method]
1) When it makes contact with a platform or surface it detects which angle it is touching upon, next it would tell the gravity to make the object move towards the contact coordinates that the collision detection is saying from its x and y axis.

[Easier/lazy method]
2) Simple, using navigation points to tell the object which way to go.

I prefer method 1 better, but I'd like to hear what works best to make the wall-stick movement mechanic works code-wise.

in Engine by (204 points)

You may want relative movement, is just matter of checking collision normal to adjust it.

Also, if you think the lazy method can be done faster for you, go for it, you can change it later for a better one ;)

1 Answer

0 votes

Well it sounds like you would need a bit more information, because I assume you'll have situations where you will have contact with both the floor and a wall in every corner. If not that probem, then a very rapid jittering, frame by frame, between the two colliders you have for a wall and a floor.

So checking the collision bodies, you could see what their rotations are relative to the world. That will be able to answer their orientations. Then you have to probably tune and compare with the character's velocity, or look at what the movement input is to decide which surface you want to choose to "stick" to.

by (5,240 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 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.