Hello Everybody,
I’ve been diving in to unity for the past month’s and there are a few questions I have about some things I couldn’t find clear answers online, mainly on scripting (maybe even scripting in general). btw I use C#.
1_# What is best performance-wise: Several gameobjects with the same script and individual inspector adjusted variables. And 1 Central script that governs movement of those gameobjects through static variables & limited use of getComponent (script) to acces the specific variables values.
OR
Every gameobject has his own version of the central script, repeating the same code serval times, but without(or less). static variables.
2#
I understand that variables are generally faster, but I’m not sure on the border when it (or if it)becomes a burden on the script. So what if a variable or a specific number, (50 in the example below) has to be repeated 5 times in 5 seperate scripts?
in each script
int moveSpeed = 50
transform.Rotate(0,0,moveSpeed);
OR
transform.Rotate(0,0,50);
OR
One static variable that’s accessed from a seperate script each time it’s needed (and its needed often)
3# Why would you use Transform as a variable instead of specificying the gameObject in a variable and accessing the transform through there (i.e. the_gameobject.transfrom)?
Thanks in advance!