using System.Collections; using System.Collections.Generic; using UnityEngine; public class XX : MonoBehaviour { private Vector3 pos; private int a = 1; void Start () { pos = transform.position; } void Update () { pos.x += 0.03f * a; if(pos.x > 5) { a = -1; } else if(pos.x < -5) { a = 1; } //pos.y = 0.5f * ((pos.x) * (pos.x)); pos.y = 0.5f * Mathf.Pow(pos.x, 2); transform.position = pos; } }