- Home /
How do i store id of certain item?
So, i am doing a raycast whenever i move (turn based game), and when the ray hits an object with tag "Door"... Here is my question, can i somehow store the information WHICH door did i bump into? I mean, i have few doors on my map.. Wouldnt want to open them all at once.
Comment
I tried to do GetInstanceID();, but all doors give the same number.
Best Answer
Answer by Kiloblargh · Jun 23, 2013 at 03:24 AM
" hit.collider.gameObject
" should do it for you.
Like this—
var doorScript : DoorScript = theHit.collider.gameObject.GetComponent(DoorScript);
if (!doorScript.isLocked)
{
doorScript.Open();
}