I must say that after days of searching this forums and trying all various
transform.Rotate
transform.rotation.eulerAngles.z,x,y
transform.localRotation
etc etc stuff that I have found in documentation + here on forums is not giving any results… all the time I am getting some weird angles, as I am reading World Rotations and not Local ones…
‘Not working’ is a bit broad, so I’ll just guess that you mean the function is returning values you don’t expect to see. In that case it might help to know what you do expect to see. For example, if you rotate the object like you said:
and then print out transform.rotation.eulerAngles and expect to see a nice increasing value on one axis and zeros on the others, then you’ll likely not get that unless the transform was aligned to worldspace in the first place.
The “Space.Self” parameter just means that the Rotate function should interpret “Vector3.forward” relative to the object and not the world. So just because the rotation is in “Space.Self” doesn’t change the fact that you’re rotating the object, i.e. changing the transform.rotation, in world space (assuming its a root object and not a child).
It may be that you want to know how much the object has rotated locally from where it started. In that case, store it at the beginning, and then calculate the difference.
if I want to read local space angels in z plane and rotate my object also in y plane I get jerky numbers again… for example z numbers jump from 15 to 190…
tx ill try that…but mind that I don’t want so set anything
I just want to know how much degrees( or radians - as you said it is easy to convert them) I have bank my object in local space… I mean as I said this should be implemented in API in some obvious way :)))
I use rigid body and AddForce to manipulate with my object quite well… and now I just want to know when my object is 14 degrees banked left or right… (ofc my object is not standing still in world coordinates but moving and turning around… but regarding local rotations that should not matter… (rigt?)
Debug.Log("LOCAL EULER Angle changed this much: " + transform.localEulerAngles);
Debug.Log("Angle changed this much: " + transform.eulerAngles);
my idea was to get local and world angles(but I you will see the numbers I get are the same both for local and global euler angles)
while my plane is just rotating in z axis everything seems to be fine
and lets leave it at z=22 degrees…
(and you may notice that transform.localEulerAngler and transform.eulerAngles are the same all the time…(am I doing something wrong here?))
and use rigidbody.AddTorque(0, 0, g * 6); to rotate my plane… so…
and… z keeps changing… (nooooo… whyyyy whyyyyyyyyyyyyyyyyyyyyyy)
Because you’re converting quaternions to euler angles; you can find lots of info about this with a search (it’s come up more than once ). Generally in cases like this, you should probably track rotations yourself.
What Eric said is true, you can’t work with the quaternion’s converted euler angles, you have to do things manually. Pythagoras wants to be your friend.