I can’t fathom this one out. I’m getting z values in my code for two different GameObjects, using position Vector3s to store the information. One of the z values always wrong - a negative exponential. I have examined the x and y and they print normally. Any explanation, please?
//declaration
Transform leftFoot;
Vector3 startStrideLoc;
//instantiation
leftFoot = GameObject.Find("leftFoot").transform;
//later, set variable
startStrideLoc = leftFoot.position;
----
//access and print the values - one statement directly after the next in my code
print("dataL:" + startStrideLoc);
//prints - dataL:(-1.0, 0.2, 0.0) -- expected value
print("dataL:" + startStrideLoc.z);
//prints - dataL:-2.33232E-07 -- where does this come from?
It’s just a rounding error. That number typed out is about -0.0000002. For all intents and purposes, it’s zero, which seems to match with your expectation. I bet if you print your x and z to more decimal places you might find they are not “exactly” what you expect either:
Thank-you. I think I’ve never got used to reading exponential number syntax, and when I had a bug in that side of the code, I irrationally blamed it on the look of that number. I’m working through to find the true cause now.
I’ll mark this thread as closed, but it could easily be deleted I guess.