using gameobject.find /

hi i just want to check if my theory is correct. in some of my scripts i have to use gameObject.Find and i was wandering if i use

gameObject.Find(“/hand”)

or

gameObject.Find(“/arm/hand”)

it will be quicker finding it as it knows it does not have a parent or it is in this parent, rather than just finding the object which could be anywhere. basically giving the computer a little help in where it will be

as well as being useful for me to find objects quicker when editing older scripts

–

1 Answer

1

It will be quicker, but nobody bothers with such questions.

Unless you’re planning to use GameObject.Find in a Update function, which would be a bad in either case. The proper way is to use GameObject.Find, and then use the cached variable later.

Its in a script which only updates at a certain time, the pause menu but i only need to find the object a couple times and it is always different to some extent. Seems pointless to catch it if im only useing a few times and each time it has to search for the new one

–