Unityで敵がプレイヤー(自分)の方を向くようにしたいため、
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class ENEMYY : MonoBehaviour 6{ 7 public GameObject Player; 8 // Start is called before the first frame update 9 void Start() 10 { 11 12 } 13 // Update is called once per frame 14 void Update() 15 { 16 float speed = 5.1f; 17 Vector3 relativePos = Player.transform.position - this.transform.position; 18 Quaternion rotation = Quaternion.LookRotation(relativePos); 19 transform.rotation = Quaternion.Slerp(this.transform.rotation, rotation, speed); 20 21 } 22}
を実行しているのですが
敵の頭(青軸)がこっちを向くような形で倒れます。敵が倒れないように(緑軸)こちらを向くにはどこに改善を施せばいいでしょうか?Lookatはいきなり向く為使いたくないです。初心者ですがよろしくおねがいします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。