- Home /
Shaking physics body container while preventing penetration
Assume that you have a en empty cup with dices in it. Dices should collide with each other and also with the internal parts of the cup.
Mission is to randomly move the dices by moving the cup-container in random positions and rotations.
The problem is, those dices will penetrate the cup in a very short time even if we make the cup thicker and/or marking collision mode to continuous, etc..
One solution is to apply those shakes to the dices in a loop by adding impulse and not changing anything related to the cup, but this does not fit the primary mission: Cup container should move in random too. That movement should be visible.
How would you solve this?
Answer by hacky97 · Nov 26, 2020 at 08:15 AM
Moving a object in positions and rotations is a non-physics action. When moving or rotating an object Unity has to come up with a solution to the applied movement or rotation. (a die might be suddenly stuck inside the container) In real world everything is done with forces. You can try to rotate the cup by giving it random force impulses. Also make sure your framerate is high and increase the physics stept in the project settings can yield better results.