Hi
I havent been using unity for a while now and I just started using it to concept a game
I was trying to set up a simple trigger using a box collider to make a target pop up
but it will only work if the box collider is not a trigger.
Here’s the code
var used : boolean = false;
function OnCollisionEnter (collision : Collision)
{
Debug.Log ("1");
if (used == false)
{
if(collision.collider.name == "Main Camera")
{
Debug.Log ("2");
SendMessageUpwards ("Activate");
used = true;
}
}
else
{
return;
}
}
Has anybody have any idea what i’m doing wrong?
change the function to OnTriggerEnter when its a trigger
allready tried that and i get nothing still is there somethng i’m missing with that code that OnTriggerEnter would need?
Very nice I meant is there anything else? other than the obvious…
Its practically the same as OnCollisionEnter except it takes a Collider as an argument instead of a Collision.
That Was It Thank You I also gathered the collider name information and stored it as a string to make it easier this is how it looks now
var used : boolean = false;
function OnTriggerEnter (other : Collider)
{
var contact : String = other.transform.name;
Debug.Log ("1");
if (used == false)
{
if (contact == "Main Camera")
{
Debug.Log ("2");
SendMessageUpwards ("Activate");
used = true;
}
}
else
{
return;
}
}
thanks again i cant believe i missed it 