using System.Collections; using System.Collections.Generic; using UnityEngine; public class Liikumine1 : MonoBehaviour { public float kx = 1.5f, sammx=0.1f, maxx=10, minx=-5; // Use this for initialization void Start () { this.transform.position = new Vector3(kx, 0, 0); } // Update is called once per frame void Update () { kx += sammx; if (kx > maxx) { sammx = -Mathf.Abs(sammx); } if (kx < minx) { sammx = Mathf.Abs(sammx); } this.transform.position = new Vector3(kx, 0, 0); } }