- Home /
Triggers not working
using
function OnTriggerEnter(collision : Collider){
if(collision.tag == "Player")
{
Debug.Log("Interacted!");
}
}
It doesn't register the collision even though I have set the object with this script to have a rigidbody and set it to "Is Trigger". The player is tagged with the exact same tag and also has a rigidbody added to it (there is indeed a mesh with which to interact with). For the record, the object with this script has an invisible collider box around it with a smaller, visible box inside that also has a rigidbody but is NOT a trigger.
Answer by jeffreywarf · Sep 04, 2013 at 08:56 PM
I just put this same script on an invisible sphere around the player (with a kinematic rigibody component and set to "is trigger") and it seems to work fine without conflicting with anything else.
Answer by Tanshaydar · Sep 04, 2013 at 07:50 PM
You should call for the gameobject like this:
function OnTriggerEnter(collision : Collider){
if(collision.gameObject.tag == "Player")
{
Debug.Log("Interacted!");
}
}
That still does not seem to work. I'm just putting it on a new invisible sphere collider around the player now and it seems to be working fine with no conflicts.
Your answer
Follow this Question
Related Questions
Objects placed manually collide, but don't if instantiated? 1 Answer
OnTriggerEnter not being called, have trigger, RB, and colliders set? 1 Answer
Trigger via Collider 1 Answer
Can't click gameobject when over another trigger? 1 Answer
Do continuous and continuous dynamic collision detection work with trigger colliders? 1 Answer