Box Collider not working

Hi,

Im did the tuturial Project1#:Stealth and now im adding my ideas into the game.
I added a gameobject “HideFromAlarm” with only a BoxCollider with IsTrigger toggle on and with size 2,2,1
Every time, the player sounds the alarm, i want to hide, and then the alarm to stop, so i made this script that i added into the gameobject “HideFromAlarm”:

void onTriggerEnter(Collider other)
	{
		Debug.Log (other.gameObject.tag);
		if(other.gameObject.tag==Tags.player)
		{
			if(lastPS.gotDetected())
			{
				lastPS.position=lastPS.resetPosition;
			}
		}

Pic:

[13257-sem+título.jpg|13257]

The problem is that is not working at all.

Thanks and sorry for my english

I don’t have the stealth project, but tried the following code in the AngryBots project and it should work. Be sure that you have, as Igor said, the collider activated on both the box and the player. I’m also pretty sure that the player tag is written with a capital “P”. The method name should also contain a capital O. And I’ve also changed the If-statement a bit.

using UnityEngine;
using System.Collections;

public class Test : MonoBehaviour {

	void OnTriggerEnter(Collider c){
		if(c.gameObject.tag.Equals("Player")){
                    //Here you have to put the rest of your own code
			print ("Colliding");
		}
	}
}

This script should be added to the box

I hope it works and good luck! :slight_smile:

I changed onTriggerEnter void OnTriggerStay and started working, tnx anyway ^^