- Home /
Why does the value I passed from a different script affects the x axis of the game object even though I inserted the value in the z axis
script passing the angle
var acos = Mathf.Acos(dotCosangle);
cosAngle = acos*180/Mathf.PI;
someInt = (int)Mathf.Round(cosAngle);
changeDialAngle.ManipulateAngle(cosAngle);
//second script where the angle is passed to
float GetDial()
{
float angleRange = minRotation - maxRotation;
float rotationNormalized = rotnorm / rotMax;
return minRotation - rotationNormalized * angleRange;
}
public void ManipulateAngle(float newAngle)
{
Debug.Log(newAngle);
rotnorm = newAngle + 0;
pointerHolder.eulerAngles = new Vector3(0,180, GetDial());
}
s![alt text][1]
Notice from the picture the meter changes direction
[1]: /storage/temp/175985-save2.jpg
The only thing that springs to $$anonymous$$d would be that your transform hierarchy is setup such that when you set your dial’s global rotation it locally rotates around its own x-axis? If I was closer to a laptop I’d test and post this as an answer but in my uncertainty I can only comment and say test this by changing the pointer holder rotation assignment to:
pointerHolder.localRotation = Quaternion.Euler(0f, 180f, GetDial());
Answer by MUG806 · Feb 15, 2021 at 08:51 PM
One of these questions where it is hard to know whats going on without knowing what the full set up for the object is, but a couple of random guesses: Is it possible that you need to use localEulerAngles instead of eulerAngles? is the object's rotation offset by a parent object? Have you tried flipping the axis around on this line:
pointerHolder.eulerAngles = new Vector3(0,180, GetDial());
//maybe try:
pointerHolder.eulerAngles = new Vector3(GetDial(),180,0);
//etc