- Home /
Moving kinematic rigidbody trigger against kinematic rigidbody collider
I have a scene where the player can "build" objects by placing them on a grid. Those buildable objects have BoxColliders and Kinematic Rigidbodies assigned to them.
As the user moves the buildable object (it floats at a certain distance above the ground) around the scene, it has a child gameobject with a BoxCollider and a Kinematic Rigidbody that follows it but it's placed on the ground:
The idea is that when the buildable object moves over something that has been already built, the box trigger of the child object should fire an event. I am talking about this situation:
It is not working as intended. The moving kinematic rigidbody trigger does not fire any events, even when the rigidbody kinematic collider is directly inside of it. The trigger is moved through the transform.position. The only explanation I can think of is that the movement is not smooth but it "snaps" to each cell of the grid. As the moving cube is of (1,1,1) size, and the cell is (1,1), the cube always moves by 1 in the given movement direction.
Are you using the correct function to detect if the Trigger is Firing an event. OnCollisionEnter() is different to OnTriggerEnter().
It would be nice to see what code you have written to get an idea of where your at.
Are using OnTriggerEnter or OnCollisionEnter ? if using OnTriggerEnter does the collider Is Trigger in Inspector View checked ?
I am using Play$$anonymous$$aker to keep things simple, that has built in Trigger support. The child GameObject that moves on the ground and follows the floating buildable object has a single FS$$anonymous$$ with a very simple state "Listener" that sends events when the trigger is entered/exited:
Also this P$$anonymous$$ action uses OnTriggerEnter in it's script code.