Assigning Values In Start () That Will Change
Hi, beginner here, I just have a quick question about how the logic of the code works. My question is, if I were to assign a value like transform.localRotation (which will change as, say, the player looks around) to a variable in the Start function, which I'm is only called once in the lifetime of the script, would the variable change, or would it stay what it was when the script was initialized? I ask because I found a script that has a variable that is assigned to be transform.localRotation in the Start function, and doesn't get changed anywhere else. However, It is possible that the value is being used in a way I don't quite understand (quaternions, man), so I just want to make sure I'm as clear on the subject as I possibly can be.
Answer by Glurth · Feb 24, 2016 at 09:13 PM
When a variable is assigned in the Start function, it will be given that value, only at that time. Thereafter the value can change, or not, depending on the program.
Often if an object is the child of another object, it's localRotation will remain constant, relative to the parent. But it's "world coordinate" rotation (not localRotation), can vary as the parent rotates around.