RigidBody ist "too heavy"

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ComanderKai77
:warning: Old Version Published before Godot 3 was released.

Hi,

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:
set_linear_velocity(Vector2(get_linear_velocity().x, -500))

Gravity Scale is 10 and the Mass is 1.

:bust_in_silhouette: Reply From: JTJonny

-Are you using _fixed_process 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

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

ComanderKai77 | 2016-06-27 21:19

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

JTJonny | 2016-06-27 21:52

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.

ComanderKai77 | 2016-06-27 22:09

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

JTJonny | 2016-06-27 22:32

I’ve uploaded the source code: Download

ComanderKai77 | 2016-06-28 09:19

:bust_in_silhouette: Reply From: mateusak

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

Continuous Cd makes no difference

ComanderKai77 | 2016-06-27 22:09

:bust_in_silhouette: Reply From: Ilya

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

Still the same problem.

ComanderKai77 | 2016-06-28 11:08

See edit above

Ilya | 2016-06-28 15:34

I got still the same problem.

ComanderKai77 | 2016-06-28 15:57

:bust_in_silhouette: Reply From: JTJonny

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.

Wow, this fixed it. Thank you.

ComanderKai77 | 2016-06-28 20:38

:bust_in_silhouette: Reply From: Noob_Maker

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.