|Topic was automatically imported from the old Question2Answer platform.
I try to implement a box pushing mechanic.
You can see a gif of my problem here.
So I have two problems
after I touch my statue (RedgidBody2D) with the Pig (KinematikBody2d) the statue never stops sliding. How do I stop this heavyweight stone Object correctly?
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.
- 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.
- If the statue doesn’t collide with the stone walls, that could be one of a couple things. Check:
- Statue should be a
- Wall should be another rigid body or (more likely) a
- 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 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