Hi,

I seem to have a problem when entering a triggerzone.
What i am trying to achieve is, whenever the player enters a certain zone (a well lit zone)
What i tried to do is, put a sphere collider on the point light and attach this script:

var playerSanity : playerSanity;

function OnTriggerEnter(other : Collider) {

if(other.gameObject.CompareTag("Player"))
{
    Debug.Log("TEST");
    playerSanity.RegenerateFear();
}

Also use the collider as a trigger.

But this doesn’t work. I also tried some tutorials that i could find on google. But they used the same method and didn’t work either. Does anyone know a way how to achieve this?

Thanks,

Darryl

var playerSanity : playerSanity; //type and identifier same? If the data type is
//“playerSanity”, the var name needs to be something different

    function OnTriggerEnter(other : Collider) {

   Debug.Log("entered trigger"); // see if the trigger was entered before checking tag

    if(other.CompareTag("Player")) //don't need "gameObject"
    {
        Debug.Log("TEST");
        playerSanity.RegenerateFear();
    }

}

not sure what the problem is though. See if adding a Debug.Log as above gets called, to rule out issues with the tag…

EDIT : sorry, forgot to mention before

You also need to have a rigidbody on one of the objects…

http://docs.unity3d.com/Documentation/Components/class-BoxCollider.html

the matrix at the bottom of this link will explain what types of objects can send trigger message

just add a rigidbody to the trigger object and set “isKinematic” true

EDIT:
now I think
DO NOT set isKinematic true, this may cause the trigger not to work (unless it moves)
as described by my experience here

but that’s only if the player does NOT have a rigidbody, I believe

Make sure ‘Is Trigger’ is checked.