【问题标题】:Unity Navigation NavMeshAgentUnity Navigation NavMeshAgent
【发布时间】:2017-09-13 21:31:35
【问题描述】:

所以在更新 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;
    }

}}

我的预制件有一个 NavMeshAgent 我重新烘焙了地形。我只需要指向正确的方向或提示

【问题讨论】:

    标签: c# unity3d navigation


    【解决方案1】:

    按照错误所说的去做,将 agent.Resume() 更改为 agent.isStopped = false 并将 agent.Stop() 更改为 agent.isStopped = true。

    【讨论】:

    • 你的意思是它不起作用?您仍然收到错误消息?
    • 好吧,我工作得很好,我需要重新启动统一的一些他妈的原因
    猜你喜欢
    • 2020-05-22
    • 2021-01-31
    • 1970-01-01
    • 1970-01-01
    • 2022-12-10
    • 2022-06-29
    • 1970-01-01
    • 1970-01-01
    • 2018-05-19
    相关资源
    最近更新 更多