eulerAngles for texture offset problem

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…

  1. 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…
  2. 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));

}

Quaternion != euler

A Quaternion has 4 values that cycle to get rotation, an euler only has 3. They really dont mix.

OK, lets assume that you have a texture that is 512 wide. You want to make a scroller that displays (-E–||–S–||–W–||–N-) What you actually need is (N–||–E–||–S–||–W–||–N–||–E) This way, when you display East, you see North, and when you display North, you see East.

Mathematically, we will say that the || between S and W is the center at 256. Now, each tick (and there are 36 of them is placed along the 512) So every 14.222 is a tick. 8 ticks over is E (113.777) and 8 from the right is N (398.222) So, this is a total distance of 284.444.

So, what you want is point = (Screen.width / 2) - (284.444 / 360 * transform.eulerAngles.y) + 113.777

And that is IF, everything is aligned as above.

Offset still jumps. :frowning:
Texture is 2048 wide, so I add your values four time bigger, but with no luck.
rotY.y = (Screen.width / 2) - (1137.776 / 360 * transform.eulerAngles.y) + 455.108;
offset = rotY.y * scrollSpeed;