Circular RigidBody2D is shortly penetrating a StaticBody2D when falling onto it.

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

Hello,

I picked up learning Godot 2 days ago and now I encountered the first problem I couldn’t solve on my own:

A small lower part of a circular RigidBody2d ball shortly penetrates a StaticBody2D ground, when falling onto it, like the edge of the ground wouldn’t stop it correctly.
Does anybody know the cause of this? I considered using _fixed_process to avoid this, but I thought it must be possible with the physics engine. GravityScale on the ball is set to 20 and vertical linear dumping to 0.5.

I am using Godot 3.0 RC1.

Thanks alot!

Greetings, Footurist

EDIT:

So, I just tried to use RigidBody2D.set_linear_velocity(Vector2(0, 0)) in _process(delta) but not even that could prevent this.

you should use _fixed_process (godot2) or _physics_process (godot3) to handle physics.

volzhs | 2018-01-22 18:13

Thanks for you answer.

So, it is normal for a RigidBody2D to act like that, when it falls into a StaticBody2D?
Because I tried both setting its linear velocity to zero on _physics_process and on _body_shape_entered. Nothing changes. :confused: The dipping happens mostly from great heights and only occasionally. It’s as though the ground gets broken sometimes (to visualize what’s wrong).

The thing happens on the scene “game” when letting the ball fall from the top of the screen a few times.
This is for practise, I am not trying to copy other apps for commercial purposes. :smiley:

Footurist | 2018-01-22 19:04

if your staticbody2d has really thin shape, it could be.
try Continuous Cd option ON of rigidbody.

volzhs | 2018-01-22 19:17

Hey, volzhs

If you have time, you could take a look at the project in the link above. However, I tried Continuous Cd aswell, both with ray or shape casting. Still happens after some time.

Footurist | 2018-01-22 19:20

I downloaded your project and run.
clicking play button does nothing. what should I look at?

volzhs | 2018-01-22 19:21

The scenes are not connected yet. You can run the scene “game” independently via the play scene button. You’ll find the scene in the folder “game” in the resource directory.

Footurist | 2018-01-22 19:23

:bust_in_silhouette: Reply From: gtkampos

I think the GravityScale is too high. Try use a small scale, like 2 or 3 and see if still happens. You could check the safe margin too, if the value is above 0.

Hey, thanks for your answer.

Yeah if it falls slower than it doesn’t happen. But that’s not the point. The ball is supposed to be jumping and falling that way.

Also, what are safe margins? I’m sorry, I am not very experienced in game development.

Footurist | 2018-01-22 19:32

:bust_in_silhouette: Reply From: volzhs

Try to increase Fixed Fps value to high like 120 at Project Settings > General > Physics > Common

Hey, thanks for your answer!

This actually almost fixed it! Almost, because the effect’s still existing but veeeery suttle.
At 200 FPS, the effect is completely gone. BUT : Setting 200 FPS does not seem like a good habit for future games. So, is there another way?

Footurist | 2018-01-22 20:13

it’s the best option to fix it AFAIK

volzhs | 2018-01-22 20:15

Yeah, but you can’t set 200 FPS if you’re publishing on Play Store, can you? And why does 200 FPS fix this in the first place? It must have something to do with synchronization with physics engine right?

Footurist | 2018-01-22 20:15

why not?
it’s just how much frequently physics calculates.

volzhs | 2018-01-22 21:24

Ok, this solved now. Thanks alot. :slight_smile:

Footurist | 2018-01-22 21:53

FYI, Fixed Fps will be renamed as Physics Fps with next version, probably stable.
so, you need to check this option later.

volzhs | 2018-01-22 23:32

Thank you, 200 FPS fixed my issue of some objects getting stuck in eachother when moving quickly.

WhoDidThis?? | 2023-03-25 14:24