transform1,敵に追随される(NavMeshSetFloat)
Random.Range(-range,range)
最小値と最大値を設定してランダムな値を取得
transform.forward
ローカル座標のZ軸。transform.forward = Vector3.right; すれば右を向く
.Slerp(from,to,t)
()内部に記載した2点の間で、円を描く
.Angle()
()内部に記載した点の間の角度
Vector3 forward
= Vector3.Slerp( transform.forward, direction, rotationSpeed * Time.deltaTime / Vector3.Angle(transform.forward,direction)
);
transform.LookAt(transform.position + forward);
対象のTransformオブジェクトを設定し、その方向を向かせる
gameObject.FindGameObjectsWithTag ("Dot").length == 0
タグに該当するゲームオブジェクトをすべて取得し、
「もしこれが0個だったら〜(無くなっていたら)」、という処理をしている
敵がメインキャラに追随するときの書き方------
public GameObject target;/*これはあとで「メインキャラ」をドラッグアンドドロップで持ってくる*/
NavMeshAgent agent;
(中略)
agent.destination = target.transform.position;
/*テンプレ的な表現。NavMeshAgentの、destinationに、位置を設定すれば、
自動的にその位置へ移動する。ここでの位置とは、target(メインキャラ)の移動具合*/
animator.SetFloat ("Speed", agent.velocity.magnitude);
/*NavMeshAgentの移動量が、velocity.sqr Magnitudeから取得できる*/