0 votes


I have a player - a RigidBody2D - which is falling from a platform.
When he hits the ground he falls "too far" und pushes himself a few pixel out of the ground (StaticBody2D).

Picture: https://postimg.org/image/xijus0gox/

The hitbox is correct.

I'm using this code to jump:
setlinearvelocity(Vector2(getlinearvelocity().x, -500))

Gravity Scale is 10 and the Mass is 1.

in Engine by (49 points)
recategorized by

5 Answers

+1 vote
Best answer

Here you go the sprite was off and you should make a scene for your player. Delete your player and add this to your scene.

Having your player in its own scene makes it easier to zero everything out and keep it zeroed out, like pos. Also, like Ilya said, its best to keep all your collision shapes at a scale of 1,1. Some shapes will act up if they are not. Just adjust the size of the points not the scale.

link to scene: player scene Download

Before I changed it:
enter image description here

Side note you might want to start using get_parent(). get_tree().get_root() is going to break your game when you start adding more stuff.

by (545 points)
selected by

Wow, this fixed it. Thank you.

+1 vote

-Are you using fixedprocess for your player, if not, try switching to it.
-Make sure your ground texture is set right

Lastly, you can check your collision shapes (while the game is running) with this button:

enter image description here

by (545 points)

I am using the fixed process and the collision shape is okay.

Is your ground moving (with code) ? , and why do you have your Gravity Scale set to 10?

The ground is static. I need the high Gravity Scale to create a realistic jump. When the scale is 1 the player falls verry slow.

Well you might need to give us more info like a picture of your whole scene or some script.

I've uploaded the source code: Download

0 votes

Sometimes when a RigidBody is too fast, it'll miss the collision box. Try activating the Continuous Cd.

by (1,109 points)

Continuous Cd makes no difference

+1 vote

Have seen the same behavior with CollisionShape2D set to the predefined concave shapes (rect, capsule).
Ended up using RayShape2D, as it pulls the player body out of the static colliders.

My guess is that physics engine does count your collision and stops the RigidBody2D, but the processing steps are discrete, so you see the bodies overlap.

Edit: Downloaded your source, you have scaled the CollisionShapes. That should always be 1,1

by (29 points)
edited by

Still the same problem.

See edit above

I got still the same problem.

0 votes

Make sure that the collision box(es) is covered every single pixel of the sprite. Like that you won't end up with the player sprite getting inside the ground. Same thing if the collision box is covering too much.

by (83 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.