- Home /
Collider child object doesn't activate oncolissionEnter
Hi, I have an enemy with a child. that child has a sphere collider of radius 10 and a script attached to it that sets a bool on true in the parent's script on collision with the player.
if my player enters the collider of the child object, nothing happens... (even though the script with the OnCollsion is on this object) if my player goes through the capsule collider of my enemy.. then the code sets off.. (this object does not have the script attached to it..)
I don't understand why the collision registers on the parent object's collider instead of the child because the script with the OnCollision is on the child object.
Answer by Tony_T · Oct 10, 2015 at 07:14 PM
I'm a bit confused on why you are using OnCollisionEnter if you want the player to be able to enter the collider. You need OnTriggerEnter and you have to make sure that the Is Trigger is checked in the Inspector. If you still have issues with the child try using tags in your script. Here is an example. Make sure the player is tagged "Player" and this script is attached to the enemy.
function OnTriggerEnter(other : Collider)
{
if(other.collider.tag == "Player")
{
//Do Something
}
}
Your answer
Follow this Question
Related Questions
Make a simple tree 1 Answer
Any help getting my trigger to fire? 0 Answers
Detach from parent OnCollisionExit 2 Answers