Quantcast
Viewing all articles
Browse latest Browse all 30

Answer by thelackey3326

Yes, you're correct. *GameObject.Find()* will return the *first* match that it finds and then it will stop searching. Assuming that this script is attached to each enemy, then what you want to use is the *gameObject* property of MonoBehaviour. A couple of notes: I see that you are only using *my_spell_source* to get to its transform property. So, you could do something like `private Transform my_spell_source;` as a field, and then in Start do `my_spell_source = transform;` Also, you've probably read that *GameObject.Find()* is very inefficient, so you should use it as little as possible. In the *Start()* you could reduce it to call Find only once and use properties of the returned object to get the other values. [GameObject.Find][1] [MonoBehaviour.gameObject][2] [1]: http://docs.unity3d.com/ScriptReference/GameObject.Find.html [2]: http://docs.unity3d.com/ScriptReference/Component-gameObject.html

Viewing all articles
Browse latest Browse all 30

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>