using System; using UnityEngine; using System.Collections; public class liikumine5 : MonoBehaviour { public float samm=0.05f; public float zmin=-15; public float zmax=-5; // Use this for initialization void Start () { } // Update is called once per frame void Update () { transform.Translate (Vector3.forward*samm); if (transform.position.z > zmax) { samm=-Math.Abs(samm); } if (transform.position.z < zmin) { samm=Math.Abs(samm); } } }