ターゲットの切り替えを矢印キーの上下で切り替えたいのですがどうすればいいのでしょうか?
ボタンはInputでQに割り当てています。
public class Lock : MonoBehaviour {
GameObject _target = null; // Use this for initialization void Start () { } // Update is called once per frame void Update () { if(Input.GetButtonDown("Lock")) { // 一番近いターゲットを取得 _target = GameObject.FindWithTag("Enemy"); } if(_target != null) { // ターゲットの方向を向く transform.LookAt(_target.transform); transform.rotation = new Quaternion(0, transform.rotation.y, 0, transform.rotation.w); } }
}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。