Rigidbody2d clipping into ground
Asked Answered
C

13

0


When the rigidbody is at high speeds, It will clip into the floor. I suspect the issue is from my custom physics settings to allow for changes in gravity. Does anyone know if theres a way to fix my code (or if theres a better way to implement changing gravity)?

Clydeclydebank answered 21/4, 2023 at 21:11 Comment(0)
C
0

Is there a way to implement Continuous CD in code? As i dont think that option does anything with custom physics...

Clydeclydebank answered 22/4, 2023 at 11:59 Comment(0)
C
0

Why do you need a custom integrator for this? You could just change rigid body's gravity scale property.

Coward answered 22/4, 2023 at 13:9 Comment(0)
C
0

Coward Would that allow for gravity to be left and right as well?

Clydeclydebank answered 22/4, 2023 at 13:15 Comment(0)
C
0

Clydeclydebank No. In that case you can use add_central_force(). When gravity needs to flip, just add the opposite of the current gravity force to nullify it, and then add the new one.

Coward answered 22/4, 2023 at 13:36 Comment(0)
C
0

Coward

So would this work to change the gravity?

Clydeclydebank answered 22/4, 2023 at 13:51 Comment(0)
C
0

Using set_constant_force seems to work, but the marble is still being affected by gravity...

Clydeclydebank answered 22/4, 2023 at 14:24 Comment(0)
C
0

Don't forget to zero-out the default gravity.

Coward answered 22/4, 2023 at 18:5 Comment(0)
C
0

Coward Thats what im stuck on...

Clydeclydebank answered 22/4, 2023 at 21:2 Comment(0)
C
0

Clydeclydebank Body's gravity multiplier should be 0

Coward answered 22/4, 2023 at 21:5 Comment(0)
C
0

Coward Doing that and setting constant y to 980 makes slopes and other things feel really jittery. Is there a way to set the global gravity while running?

Clydeclydebank answered 23/4, 2023 at 9:6 Comment(0)
C
0

Clydeclydebank You should change the gravity force only once, not perpetually and try to use *_central_force() insted *_force(). Alternatively you could apply central impulse every frame but that'd make the behavior frame-rate dependent.

Coward answered 23/4, 2023 at 10:54 Comment(0)
S
0

What version of Godot are you using?

This is a known issue in 4.0
https://github.com/godotengine/godot/issues/72674

Skardol answered 23/4, 2023 at 14:53 Comment(0)
C
0

Skardol 4.0. Thanks for notifying me of the bug!

Clydeclydebank answered 28/4, 2023 at 20:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.