This one has to be simple, but I can't find the words to Google this.
I have a script attached to an object in Unity. From that script, how do I access the object's name or other properties? I've read this page, but it doesn't seem to address my question.
I've tried Gameobject.name and this.name, but I can't make them work.
Oh my God, I needed a '==' instead of a single '='. What a rookie mistake. Thank you, everyone. You're always so helpful.
answered Jun 21, 2013 at 06:27 AM
according to your code here, you are accessing the name of the gameObject that you attach this script to, not to another gameObject
this wouldn't really work in a collision situation as you want to find out what your current gameObject collided with, it cannot collide with itself.
you may want to look up triggers too http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnTriggerEnter.html
ive found this a good method for finding WHAT you have collided with.
answered Jun 21, 2013 at 06:31 AM