我正在开发一款 RTS 游戏。我做了一个正常的移动脚本,我增加了代理的停止距离,这样他们就不会互相看着,也不会抽那么多。但他们还是互相打了起来。
我找不到让代理互相避开而不是互相推挤的方法。或者以某种方式忽略物理,同时仍然试图避免彼此。这是点击移动的代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class moveTest : MonoBehaviour {
NavMeshAgent navAgent;
public bool Moving;
// 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))
{
Moving = true;
if (Moving)
{
if (Physics.Raycast(ray, out hit, 1000))
{
navAgent.SetDestination(hit.point);
navAgent.Resume();
}
}
}
}
}