- Home /
mesh.uv question
I want to rotate the UV texture between points (current point, and previous point) on an uneven terrain! it occurs to me, find the angle between the current point and the previous point, and that value, assign it to the rotation of the texture.
Answer by UnityCoach · Oct 24, 2018 at 04:12 PM
Interesting idea. I'm not going to argue that walls aren't built like that. Your world, your rules right ;)
Let me help you find the angle. Let's take two Transforms, p1
and p2
. You can easily get the direction from p1 to p2 :
Vector3 dir = (p2.position - p1.position);
Then you want to project this on a flat plane (XZ)
Vector3 flatDir = Vector3.ProjectOnPlane (dir, Vector3.up);
So you can measure the angle between the two.
float angle = Vector3.Angle (dir, flatDir);
That said, if you set UVs at the four corners of your texture (0,0 - 0,1 - 1,0 - 1,1) and move vertices around, it'll will rotate and stretch the texture.
Your answer
Follow this Question
Related Questions
Flip over an object (smooth transition) 3 Answers
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
UV Mapping: extra pixels either side 1 Answer
Rotating Character 1 Answer