- Home /
Question by
CYVISUALEFFECTS · May 12, 2013 at 02:46 PM ·
collidertriggerplayer
Make trigger be activated only by the player
How to the collider be triggered only by the player?
Comment
Best Answer
Answer by fjalla · May 12, 2013 at 04:09 PM
You should try to search for your question first, but here you are anyway:
function OnTriggerEnter (other : Collider) {
if(other.tag == "Player") {
//DO SOMETHING
}
}
function OntriggerEnter (other : Collider) {
if(other.tag == "Player") {
Application.LoadLevel ("END");
}
}
Answer by Mexallon · May 12, 2013 at 05:04 PM
Do determine the object you just collided with you can examine the Collider passed to the function or more specific the gameobject like in my example.
C#:
void OnTriggerEnter(Collider c){
if(c.gameObject.name == "Player")
Debug.Log ("Player triggered");
else
Debug.Log ("Something else triggered");
}