0 votes

what I mean is that I have created a player, and it goes towards a wall, it gets a few pixels inside the wall, even if the player stops moving, it stays a fex pixels inside the wall.

This affects me because it also happens with the floor, so sometimes when I jump, the player gets a bit inside the floor, so then when I try moving, the player gets stuck.

I am using the default collision of the CollisionShape2D, the maxDepth is set to 0, the gravity works with the default RigidBody2D gravity, the player moves horizontally with setlinearvelocity () and I have no idea how I could fix this

in Engine by (131 points)
edited by

1 Answer

+1 vote
Best answer

This took me a while to figure out when I began. You see, a lot of problems will come up if you don't set up your colliders properly, not only getting a little under the floor.

The most important thing you have to know is this:
Every side of a collider that is intended to interact with another collider should have another collider pointing in that direction using a RayShape2D. The function of this shape is not to collide, but to push away.

Example:
The bottom side of your player collider is intended to interact with the ground collider, therefore you setup another collider using a RayShape2D pointing downwards. This will prevent any problems, such as getting stuck, getting under the ground, etc.

by (1,124 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.