你好,所以我在一个RTS游戏上工作,所以我会控制更多的1分钟,但是我尝试并添加另一个仆从,并命令他们,他们都到了点,然后他们看对方像这个http://imgur.com/a/uHwjG。这些仆从移动的代码如下:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class moveTest : MonoBehaviour {
NavMeshAgent navAgent;
// Use this for initialization
void Start () {
navAgent = GetComponent<NavMeshAgent>();
}
// Update is called once per frame
void Update () {
move();
}
void move()
{
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Input.GetMouseButtonDown(1))
{
if (Physics.Raycast(ray, out hit, 1000))
{
navAgent.SetDestination(hit.point);
}
}
}
}发布于 2017-09-12 04:02:58
代理人将尽可能接近这个位置。既然你告诉两个人去同一个位置,他们就越往前挤。您可能希望增加停止距离,或者向random.insideunitsphere中添加一个hit.point,这样它们看起来更像一个组。
https://stackoverflow.com/questions/46164998
复制相似问题