using UnityEngine; using System.Collections; /* This script is used to make move an object in a hover-like motion - or to be more precise, in a sinus pattern. The public parameters are: Frequency -- sets the speed of the motion Amplitude -- sets the distance travelled by the motion Time Offset -- shifts the movement in time (useful when using the script on multiple objects) Move X,Y,Z -- set the direction in which the object should hover */ public class AnimateTexture : MonoBehaviour { // Setting default script parameters public float speedX = 1.0f; public float speedY = 1.0f; // Private variables for internal script parameters private Renderer r; private Vector2 offset; void Start () { // Create a reference for the renderer component r = GetComponent(); } void Update() { // Determine the texture offset, multiply by time since start and speed, // and apply to the material offset = new Vector2 (Time.time * speedX, Time.time * speedY ); r.material.SetTextureOffset ("_MainTex", offset); } }