I have a globally declared private dictionary variable named joint that takes a string and a class A
This gets populated in the Start() function. I use joint later on in a function named SetPosition() which gets called via Update(). And I use joint in this way:
var position = joint_.transform.localPosition * 2;_
I was expecting joint to maintain its original localPosition values over time considering how it was populated in the Start() function, but for some reason, when I output it, the localPosition in joint changes over time even though I only use it in the arithmetic. I never assign anything to joint.
There is another variable (modifiedJoint) of the same type and contains the same data as joint, but this is the one I expect to have the changes over time and is populated in SetPosition(). It gets assigned the localPosition changes based on the arithmetic above.
I was intending to use joint as a container for the original transforms, so that when trying to do arithmetic, I still have the original positions of the gameObject. I need this info because I am trying to move a gameObject forward/backward, and I need to return the gameObject to its original position once it moves “backwards”. But evidently the *joint position values change, and I don’t know why they do.
Is doing arithmetic with transform.localPosition enough to change a gameObject’s transform automatically without assignment?