Unity Navigation NavMeshAgent

时间:2017-09-13 21:31:35

标签: c# unity3d navigation

所以这在更新Unity之前工作正常,但在我更新后我一直得到这两个错误

UnityEngine.AI.NavMeshAgent.Resume()'已过时:`设置isStopped为false而不是'

UnityEngine.AI.NavMeshAgent.Stop()'已过时:`设置isStopped为true而不是'

这是我的代码

public class Navigation : Interaction
{
public float RelaxDistance = 5;

private NavMeshAgent agent;
private Vector3 target = Vector3.zero;
private bool selected = false;
private bool isActive = false;

public override void DeSelect()
{
    selected = false;
}

public override void Select()
{
    selected = true;
}

public void SendToTarget()
{
    agent.SetDestination(target);
    agent.Resume();
    isActive = true;
}

void Start()
{
    agent = GetComponent<NavMeshAgent>();
}

// Update is called once per frame
void Update()
{
    if (selected && Input.GetMouseButtonDown(1))
    {


        var tempTarget = RtsManager.Current.ScreenPointToMapPosition(Input.mousePosition);

        if (tempTarget.HasValue)
        {
            target = tempTarget.Value;
            SendToTarget();
        }

    }

    if (isActive && Vector3.Distance(target, transform.position) < RelaxDistance)
    {
        agent.Stop();
        isActive = false;
    }

}}

我的Prefabs有一个NavMeshAgent并且我重新调整了地形..我只需指向正确的方向或提示

1 个答案:

答案 0 :(得分:0)

只需执行错误说明并将agent.Resume()更改为agent.isStopped = false,将agent.Stop()更改为agent.isStopped = true。