123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class TestItem : MonoBehaviour {
- private Rigidbody mRig;
- void Start () {
- mRig = this.GetComponent<Rigidbody>();
- }
-
- // 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;
- }
- }
- }
|