- Home /
Why am I getting "MissingMethodException" error message?
My script is
function OnCollisionEnter(collision:Collision) {
if(collision.gameObject.name("Station")){
Debug.Log("hit!");
}
}
And I keep getting "MissingMethodException: Method not found: 'UnityEngine.GameObject.tag'." Error message, I cant figure out why. I swear I've gotten collision to work with this script in the past, what am I doing wrong here?
Answer by Eric5h5 · Dec 27, 2010 at 01:58 AM
You're trying to treat collision.gameObject.name like it's a function, but it's not. You want to compare the name to a string: .name == "Station"
rather than .name("Station")
.
Thanks much Eric! I actually realized that shortly after I posted this, I guess I need to check the references a little better before posting.
Your answer
Follow this Question
Related Questions
Weird collision error when using waypoint script... 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Script Error!! 1 Answer
How to implement: if hit with certain force? 2 Answers
Error message, HELP!!! 1 Answer