- Home /
How to get OnTriggerEnter to react to only something with a specific name.
I have created a respawn system where, when you touch my "smog", you get placed where the last respawn point you touched is. However, my problem is that I have other things in my scene that, when they touch the smog, move me to the respawn point. I tried making the code be:
OnTriggerEnter (other. Collision) { if (other.gameObject.name == "First Person Controller")
//the rest of my script
}
But I kept getting the error: Script error: OnTriggerEnter This message parameter has to be of type: Collider The message will be ignored.
What do I have to do??
Answer by Peter G · Jan 13, 2011 at 02:15 AM
OnTriggerEnter (other. Collision) { if (other.gameObject.name == "First Person Controller")
//the rest of my script
}
should be:
OnTriggerEnter (other : Collider) { if (other.gameObject.name == "First Person Controller")
//the rest of my script
}
"name" is a property of Unity's "Object", so you don't need to query .gameObject first.
Your answer
