x


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?

more ▼

asked Dec 27 '10 at 01:47 AM

Wes 1 gravatar image

Wes 1
40 18 18 22

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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").

more ▼

answered Dec 27 '10 at 01:58 AM

Eric5h5 gravatar image

Eric5h5
81.5k 42 133 529

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.

Dec 27 '10 at 02:01 AM Wes 1
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5270
x2584
x2029

asked: Dec 27 '10 at 01:47 AM

Seen: 3029 times

Last Updated: Dec 27 '10 at 01:47 AM