- Home /
How to make Physics2D more "stable"
Hello, I'm currently developing a simple tower game where you have to stack different 2D sprites(rigibody2D) on top of each other and prevent them from collapsing. It works pretty well though I have one basic problem:
Once I stack different sprites on top of each other (in the game) they start to awfully wiggle and then slip away (as seen on the picture below). I tried to solve it with a high friction 2D material, but it didn't help. The collision detection is set to "continous" since I'm dragging the objects with my mouse.
Does anyone have a good idea how to prevent the objects from slipping away too easily?
Thanks for any help!!
Not sure you need to have "Continuous" on...? Have you tried playing with the gravity setting in project settings? This may help(reduce it). Have all your objects got the high friction $$anonymous$$aterial on them, and have you altered all the Physical $$anonymous$$aterial settings to max friction. Also try changing the mass of your blocks in the rigidbody settings. And the interpolate settings as well... Let me know if any of this helps, I will try to think of something else if not.
I need continous collision detection. Otherwise while I drag the object it won't properly collide with other objects that are already in scene.
Neither of it helped. With higher gravity the objects directly slipped of the surface (to the right side). Tried to manipulate the sleep time but that didn't work either. Could it be that the flat surface of the ground object is causing the troubles?
I now increased the linear drag of the rigidbody which seems to $$anonymous$$imze the problem. It will slow down the fall of object though, but I guess I'll better have a slow falling object than a collapsing tower.. ;)
I meant lower the gravity so that it is not pulling them down with as much force, sorry for the ambiguity. You could add a downwards force while in falling state to increase the fall speed, then end this force upon contact. Possibly with a damping anti fall force applied when contact is made to slow it down for resting nicely. Did you play with the $$anonymous$$ass of the objects, this can make a big difference sometimes without having to alter gravity.
You normally only need continuous when objects are moving very fast to stop them passing through other objects. $$anonymous$$aybe your drag does need this but in general it is used for fast moving projectiles.
I had forgotten about drag(Doh!), you can change the drag value of your block upon contact, ramp it up. Then when no contact reduce it back to 0.
It does help a bit. but the more objects are on top (> 3), the faster it starts to slip out. Can I maybe somehow ignore collision up to a specific amount?
Your answer
Follow this Question
Related Questions
Remove Drag/Friction 1 Answer
Changing friction from code not working (2D) 2 Answers
sharedmaterial.fricion behaivior in actual game 0 Answers