- Home /
GameObject.Find vs GameObject.FindWithTag
I noticed that using GameOBject.FindWithTag will only get my players position once in the beggining of the game, even when called in update. However using GameObject.Find seems to fix the issue and work correctly. Though I am really curious as to why FindWithTag isnt getting the updated location of my player
Answer by Jwizard93 · Jul 09, 2017 at 10:36 PM
I am unable to recreate the issue it works fine. But there are better ways to do this anyway. If you find the object once just store it, no need to find it every frame. When you are doing a lot of finding the GameObject.Find... methods are slow and consumptive. There's a better method, I see people explain on this site all the time, Idk what it is. But in your case you should just store after the one find.
Answer by DiGiaCom-Tech · Jul 10, 2017 at 02:34 AM
Yes ... the best method (IMHO) is to use find in your 'onStart' event and store the gameObject or transform into a local 'Player' variable. Then in your update (or any other) local event you can access or change 'Player' information as needed.