Confused about Inspector values and what is reported by Debug

I’m trying to set an objects speed when traversing slopes. I want a 1960’s VW bus style physics (ie. you can go as fast as you can down hill, but uphill is a strain and a good running start helps). I used the players rotation to see if it was going uphill or down. I started to get odd velocity numbers so I displayed rotational values in a debug.log. These didn’t correspond to the values in the inspector. The Inspector’s value for a rotation of one axis is 122.792 but the debug.log shows -0.2603793 for both local and world. I don’t think local and world should be the same and one of them at lease should be the same value as what is shown in the inspector. Why am I getting what looks like normalized values? Am I missing something obvious?

Debug.Log ("World = " + model.transform.rotation.z.ToString () + "  Local = " + model.transform.localRotation.z.ToString ());

If you look at the API for localRotation, you’ll see it returns a Quaterion. The Inspector communicates rotation values in degrees, like we’re used to dealing with, but quaternions are useful in various mathematical operations. You can get the euler angle by doing:

model.transform.localRotation.eulerAngles.z
2 Likes

And you would be correct sir! I knew something was wrong as the world and local should not have been the same. I walked by the obvious and started digging for complicated reasons. I do have my bad days.

Thanks for the course correction.