エリアに侵入したらターゲットの方向に近く

エリアに侵入したらターゲットに向きを変えまっすぐ進む。
using UnityEngine;
using System.Collections;
public class Hunter1 : MonoBehaviour {
public float speed;
public GameObject target;
void OnTriggerStay(Collider other){
if (other.gameObject.CompareTag ("Player")) {
transform.rotation = Quaternion.Slerp (
transform.rotation,
Quaternion.LookRotation (target.transform.position - transform.position),
Time.deltaTime * 10);
transform.position += transform.forward * Time.deltaTime * speed;
}
}
}
Unity Code Memo
他のコースを見る
エリアに侵入したらターゲットに向きを変えまっすぐ進む。
using UnityEngine;
using System.Collections;
public class Hunter1 : MonoBehaviour {
public float speed;
public GameObject target;
void OnTriggerStay(Collider other){
if (other.gameObject.CompareTag ("Player")) {
transform.rotation = Quaternion.Slerp (
transform.rotation,
Quaternion.LookRotation (target.transform.position - transform.position),
Time.deltaTime * 10);
transform.position += transform.forward * Time.deltaTime * speed;
}
}
}
エリアに侵入したらターゲットの方向に近く