「特定の方向を向かせる」の編集履歴(バックアップ)一覧はこちら
「特定の方向を向かせる」(2015/05/26 (火) 19:01:16) の最新版変更点
追加された行は緑色になります。
削除された行は赤色になります。
target = GameObject.Find("Player").transform;
オイラー角を用いる
transform.LookAt(target);
クォータニオンを使う
transform.rotation = Quaternion.LookRotation(target.position - transform.position);
thisから見て、targetの方向を向かせる
特定の座標にスムーズに向く
private void SmoothLookAt2(Vector3 target)
{
Vector3 newRotation = Quaternion.LookRotation(target-transform.position ).eulerAngles;
newRotation.x = 0;
newRotation.z = 0;
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(newRotation),
3f*Time.deltaTime);
}
target = GameObject.Find("Player").transform;
オイラー角を用いる
transform.LookAt(target);
クォータニオンを使う
transform.rotation = Quaternion.LookRotation(target.position - transform.position);
thisから見て、targetの方向を向かせる
特定のObjectの方にスムーズに向く
private void SmoothLookAt(GameObject target)
{
Vector3 newRotation = Quaternion.LookRotation(target.transform.position-transform.position ).eulerAngles;
newRotation.x = 0;
newRotation.z = 0;
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(newRotation),
3f*Time.deltaTime);
}
特定の座標にスムーズに向く
private void SmoothLookAt2(Vector3 target)
{
Vector3 newRotation = Quaternion.LookRotation(target-transform.position ).eulerAngles;
newRotation.x = 0;
newRotation.z = 0;
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(newRotation),
3f*Time.deltaTime);
}