- Home /
Unity Collider Penetrating detection
Hey guys,
I'm currently working on a project which has a Hammer-and-Nail system to implement, and my question is how to track the child collider for a enter-stay-inside-exit process of collision?
The basic idea is the player could nail a nail into some object, the nail itself is a GameObject with basically 5 child: Head, Middle, End, Upper, and Lower. Each of these object was given a collider.
The nail will first detect if it actually touching any object when player hit the nail, then it will create a group GameObject in the scene and put itself and the target object as a child of that group object, in order to simulate the nailed-together effect (i.e. transform and collision).
But since we want to implement the functionality that the player can nail two objects together, which means the nail will penetrate one object and then collide with another object then repeat the nailing process I just mentioned.
But now the problem is that every time since I nailed the nail into the object (the head is in the object), the collision detection seems to stop working. And even I eventually move the nail through the object, which means move the heads out, the collision detection is still not working, the OnCollision series function never triggered.
I've considered using a fixed joint on the object, but the actual physics behavior seems to be weird. So guys how should I detect a penetrating collision? Or how should I detect the child collider separately while putting them together as a single object?