Game Development Reference
When creating materials in Unity you may have seen properties for x and y
offsets. These values are used to adjust the alignment and location of a texture
on a polygon's surface. If these values are adjusted constantly with each game
loop, the texture will appear animated. This is an effective way of creating an
animation that doesn't involve modeling or extra polygons. It is often used in
creating sky and water effects.
Unity Hands On
Step 1. Create a new Unity project.
Step 2. In the Scene add a plane.
Step 3. Create a new material and add it to the plane.
Step 4. Find a seamless texture of your choosing from the Web.
Step 5. Drag and drop the new texture into the Project.
Step 6. Add the texture to the material. It should appear on the
surface of the plane.
code in Listing 2.22 .
of an Object
var uvSpeed: Vector2 = new Vector2(0.0f, 1.0f );
var uvOffset: Vector2 = Vector2.zero;
uvOffset += (uvSpeed * Time.deltaTime );
Step 9. Play. The texture will move across the surface of the plane. To
change the direction of the movement, modify the x and y values for
the uvSpeed variable in the script. The LateUpDate() function is similar
to the Update() function in that it executes for an object every game
loop. However, with LateUpDate() it occurs as the very last function
called for an object so that it can take into consideration any related
processing occurring in the same game loop.
file and enter the same code from Listing 2.22 . Attach this script to
polySurface437. This is the surface of the conveyor belt in the room
where you placed the curtain. Play and watch the conveyor move!