- Home /
How can i Prevent Kinematic object not to pass through another rigidbody object
Hi All, I am developing an oculus Home like project where i am facing a problem of object passes through walls and other objects. The scene is described as, I have an object that has Box Collider and an Rigidbody (Gravity false , Kinematic true) A wall and a Floor with Box Collider and Rigidbody(Gravity false , Kinematic False) I am moving an object with hands movement. Translate object near and far using thumbstick, the problem is that when i move object far the object pass through the wall and floor. As you can see in the image below the object is passing through in the walls and the floor. Please help me and suggest a better solution. Thanks in advance.
Answer by Owen-Reynolds · Dec 20, 2019 at 05:39 PM
One solution is not to have it be kinematic. Let it be a real physics object, but tightly controlled by you. Turn off gravity and each frame manually set the speed to "very fast, towards where the player is trying to put it, zero if already there." This takes some work to have it not bobble when the player is trying to force it though a wall. I've done this, it takes lots of tweaking, and it gives a puppy-like effect.
--
The other way is to leave it kinematic and do a box-cast or sweep-test when-ever it needs to move. If it hits something, have it go only to the hit-location. Those functions aren't easy.