- 最后登录
- 2019-12-25
- 注册时间
- 2012-8-24
- 阅读权限
- 90
- 积分
- 71088
 
- 纳金币
- 52352
- 精华
- 343
|
Cube的 waypoint寻路代码- 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];
- }
-
- }
- }
复制代码 |
|