using System.Collections; using System.Collections.Generic; using UnityEngine; public class TestItem : MonoBehaviour { private Rigidbody mRig; void Start () { mRig = this.GetComponent(); } // Update is called once per frame void Update () { } private void LateUpdate() { Move(); } private float cd = 1; private float fullTime = 0.5f; private float duringTime; private void Move() { if(duringTime > fullTime) { duringTime = -cd; } if(duringTime < fullTime && duringTime >=0) { duringTime += Time.deltaTime; this.mRig.AddForce(Vector3.right * 2); } else { duringTime += Time.deltaTime; } } }