追いかけてくる敵を作る(追跡機能)




追いかけてくる敵
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// ★追加する(ポイント)
using UnityEngine.AI;
public class Chase : MonoBehaviour
{
public GameObject target;
private NavMeshAgent agent;
void Start()
{
agent = GetComponent<NavMeshAgent>();
}
void Update()
{
// ターゲットの位置を目的地に設定する。
agent.destination = target.transform.position;
}
}








BattleTank(基礎/全31回)
他のコースを見る



追いかけてくる敵
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// ★追加する(ポイント)
using UnityEngine.AI;
public class Chase : MonoBehaviour
{
public GameObject target;
private NavMeshAgent agent;
void Start()
{
agent = GetComponent<NavMeshAgent>();
}
void Update()
{
// ターゲットの位置を目的地に設定する。
agent.destination = target.transform.position;
}
}








追いかけてくる敵を作る(追跡機能)