RidgidBody shall stop sliding and how to prevent the pushing through the walls.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By letsgamedev

Hi there,

I try to implement a box pushing mechanic.

You can see a gif of my problem here.

So I have two problems :slight_smile:

  1. after I touch my statue (RedgidBody2D) with the Pig (KinematikBody2d) the statue never stops sliding. How do I stop this heavyweight stone Object correctly?

  2. I can push the statue with the Pig inside of the map walls. Is there a way, so the statue cannot be pushed in the wall?

I like Godot (using 3.1-alpha currently) a lot but I just get stuck in those physics, colliding, area stuff all the time -.-

Thanks for any help in advance.

Tom

:bust_in_silhouette: Reply From: markopolo
  1. Have you set the RigidBody2D 's linear damping to a value greater than zero? That’s how I simulate floor friction for top-down views like the one from your gif.
  2. If the statue doesn’t collide with the stone walls, that could be one of a couple things. Check:
  • Statue should be a RigidBody2D.
  • Wall should be another rigid body or (more likely) a StaticBody2D.
  • Statue and wall bodies need shapes (check by enabling collision shapes in debug menu).
  • collision layers for the statue and the wall have to match up. You probably have player, wall, and statue all on the same layer and with the same mask.

Or do you mean that the statue does collide with walls correctly, but then you can push it into walls using the pig? If that’s the case, then the issue is that the physics engine (purposefully) never prevents a kinematic body from moving - the physics engine will never stop the pig from pushing the statue, even if the statue ends up in a wall. You will have to change the pig to not be a kinematic body (I use rigid bodies even for player controlled physics objects) or add some code to recognize when the pig is about to push the statue into the wall and prevent that somehow.

Thank you and sorry for my late response (found it in my spam filter -.-)

For the sliding statue problem: The linear dump was on 100+ and nothing worked. My mistake was, that I toggled Custom Integration to On so linear dump had no effect. Now the Statue stops sliding.

And the integration of _integrate_forces did the trick with the push through the walls issue.

So thank you for pushing me to the right direction^^

letsgamedev | 2018-10-22 18:20

glad you found the solution, even if it wasn’t mine :smiley: I’ll have to remember that about custom integration to suggest about problems like this.

markopolo | 2018-10-22 18:45

Can you provide more information how you solved this with integrate_forces? I am having the same problem (a kinematic player is able to push a rigidblock block through a wall, which should not happen)

dbanfield | 2019-07-27 20:03