AIのモンスターパトロールのユニティ



    public Transform PoOne;
    public Transform PosTwo;
    public GameObject Enumy;
    public GameObject Player;
    
    void Start()
    {
        GetComponent<NavMeshAgent>().destination = PosTwo.position;
    }
    void Update()
    {
        if(Vector3.Distance(Player.transform.position,transform.position)<10&& Vector3.Distance(Player.transform.position, transform.position)>2)
        {
           
            GetComponent<NavMeshAgent>().destination = Player.transform.position;
            
        }
        else if(Vector3.Distance(Player.transform.position, transform.position) <= 2)
        {
            Enumy.GetComponent<Animator>().SetBool("Enum", true);
        }
        else
        {
            if (Vector3.Distance(transform.position, PosTwo.position) < 0.1f)
            {
                GetComponent<NavMeshAgent>().destination = PoOne.position;
            }
            if (Vector3.Distance(transform.position, PoOne.position) < 0.1f)
            {
                GetComponent<NavMeshAgent>().destination = PosTwo.position;
            }
        }
       
    }


ここに画像を挿入説明

ここに画像を挿入説明オブジェクトのスクリプト記述されたコピーが行く必要後、モンスターは自動的にあなたがパトロールに行くポイントに応じて設定され、あなたは我々が設定され、いくつかのポイントを得るために注意を払う必要があり、Y軸は、そうでない場合は、彼が最初にあったであろう、地形焼くの範囲内にあることが必要ですサークルでラウンド行くのポイントは、次のポイントをパトロールしません。

不備は、展覧会をしてください。

おすすめ

転載: blog.csdn.net/weixin_44370124/article/details/91799005