I have a plane with transparent texture for HUD compass line. (-E–||–S–||–W–||–N-).
My script changes the offset of the texture. (rotating around Y axis).
But I have a problem…
- if I use transform.rotatation.y, everything works fine, but when rotation reach 180, offset begins to move backward…
because of that I used eulerAngles… - if I use transform.eulerAngles.y, it works fine, no opposite offset movement, but if my rotation reach 0 or 360, offset jumps a bit backward (ca 3 degrees). So, for example…if you reach 320 degrees on your compass, it jump back to 290 degrease and continue rotation from this place. That means you can see 300 → 310 → 320 → 290 → 300 → 310 → 320 → 330 → 340 and so. From what I read it is because eulerAngles rotates 0-360 and if I use these values (multiplied by rotationSpeed float number) there is a jump from 0 to 360 or 0 to 360 off course.
Any idea how to solve this to make it rotating correctly?
here is the script
var rot : Quaternion;
var offset : float;
function Update() {
rot.y = transform.eulerAngles.y;
offset = (rot.y * scrollSpeed);
renderer.material.SetTextureOffset ("_MainTex", Vector2(offset, 0));
}