How to prevent RigidBody from going through other colliders

I have a coin RigidBodyand walls around it with boxed colliders. For reference, I applied the following code to a coin.

private void OnMouseDown() 
{
    rigidbody.AddForce(30.0f, 0f, 5.0f, ForceMode.Impulse);
}

But sometimes a coin goes through walls, but when I increase the speed from 30 to 50 points, it goes through walls from the first click. I googled a lot and still have not received anything except the DontGoThroughThings script, which does not work for me, or I really don’t know how to use it.

I always added continuous dynamics on the coin and continuous collision detection on the walls, but still does not work.

+4
source share
5 answers

, , ( , ), . , , , , . , 100 1 , , , , , a b, , .

.

, , , , .

, , , , .

, - . , raycast. raycast , , , raycast, , , .

, . , , .

+4

, "". , , gameObjects .

+1

.

, Rigidbody "Is Kinamatic" False, Is Triggger: false,

"Is Trigger" False.

0

, , , ,

0

.

0

Source: https://habr.com/ru/post/1524539/


All Articles