- 最后登录
- 2021-7-6
- 注册时间
- 2012-12-27
- 阅读权限
- 90
- 积分
- 76145
- 纳金币
- 53488
- 精华
- 316
|
- using UnityEngine;
- using System.Collections;
- public class SSDsScript : MonoBehaviour {
-
- public GameObject[] cube;
- public Vector3[] cubePosition = new Vector3[4];
- public Vector3 target = Vector3.zero;
- public int n = 0;
- void Start()
- {
- for (int i = 0; i < cube.Length; i++)
- {
- cubePosition[i] = cube[i].transform.position;
- }
- target = cubePosition[0];
- }
-
- // Update is called once per frame
- void Update () {
- transform.position = Vector3.Lerp(transform.position, target, Time.deltaTime * 5f);
- transform.LookAt(target);
- if (Vector3.Distance(transform.position,target)<0.5f)
- {
- n++;
- n %= 4;
- target = cubePosition[n];
- }
-
- }
- }
复制代码 |
|