If its possible, how would i go on about getting exactly this value of the object? I tried using euler angles which doesnt unfortunately work. im trying to get this value for a steering wheel and it would make my job much easier.
If it’s only-editor-thing, you can do it by below:
void DoSomethingToInspectorRotation()
{
var so = new SerializedObject(transform);
var eulerAngleHint = so.FindProperty("m_LocalEulerAnglesHint").vector3Value;
// do something...
}
There may be no solution in runtime, I think.
Are you asking how to get the rotation of an object? That’s pretty basic stuff, to be fair, unless you’re having the issue where it’s a child of something, then you’d want transform.localRotation
. But that would give you a Quaternion, and you’re probably used to seeing Euler(which shows in the Inspector). So I would research into both of those and get a good grasp on Gimbal Lock, which is the whole reason Unity uses Quaternions instead of Euler.
But to convert it from Quat to Euler is simply:
Vector3 quatToEuler = transform.localRotation.eulerAngles;
It’s important to note the euler angles shown in the inspector are not representative of the euler angles you’ll get from that of either the transform.rotation
or transform.localRotation
euler values. They’re just there to be human readable, and there’s a high chance they will be different from what the values are under the hood.
This is a case of where you want to seperate the runtime/display values to the actual values you’re working off. Just have a float in your script that stores your rotation around this pivot, and when it’s updated, rotate the steering wheel with Quaternion.AngleAxis
for example.