I have tried OnTriggerEnter and OnCollisionEnter but in neither one can I get the game object register the collision, could someone tell me how to get the object to notice collisions with objects that have the tag ‘tower’.
void OnCollisionEnter (Collision col)
{
if(col.gameObject.tag == “tower”)
{
//Do something
}
}
Just google a few seconds…
If your Collider isTrigger is true
you can get the collided game object using OnTriggerEnter
like this:
void OnTriggerEnter(Collider coll)
{
if (coll.tag == "Tower"))
Debug.Log("Collided with some tower");
}
Or, if your Collider isTrigger is false
, you can use OnCollisionEnter
:
void OnCollisionEnter(Collision coll)
{
if (coll.gameObject.tag == "Tower"))
Debug.Log("Collided with some tower");
}
Hey! @Ebil, even if I wanted to, I can’t up-vote any answers as I have to have 15 reputation