If i put this sentence on the update function it will lag me a lot due to frame-to-frame check
laser l = GameObject.FindWithTag (“Player”).GetComponentInChildren ();
So to avoid that lag, i usually do the cache stuff like this on awake/start function:
target = GameObject.FindWithTag(“Player”).transform;
To prevent using the FindWithTag stuff on the update function. The problem is, when i used that (target sentence) i need a Transform var (Transform target;) because im using a transform value. But with the first sentence i dont know for sure what kind of var is… :S
No i think you are not understand me. I mean im using c# and Laser l= var l: laser on javascript. I
I want to cache the another part… I mean its in the update function so… i dont wanna do each frame a GameObject.FindWithTag(“Player”).GetComponents(); So i have to cache that sentence on awake/ start function for not causing lag…
Target sentence was an example… So if i want to check the player position on the update function and i dont wanna have lag at all ill cache that sentence on the start/awake void like this:
So… if i do that, i can use “target” on the update function without any lag… So thats a transform var, i want to do the same thing with this (no with laser, because var target:laser on the var declaration and laser target=… its the same):
laser l = GameObject.FindWithTag (“Player”).GetComponentInChildren ();
“i dont wanna do each frame a GameObject.FindWithTag(“Player”).GetComponents(); So i have to cache that sentence on awake/ start function for not causing lag…”
Because i dont know how to cache that sentence ^^. In the case of “target” i can save that sentence in a var with a Transform value due to is a transform type. I cant save the "GameObject.FindWithTag(“Player”) as a transform value.
I mean i know what to do, but i dont know how to do it…