두 점 사이의 각도를 계산할때 사용하는 API 함수
static Quaternion LookRotation(Vector3 forward, Vector3 upwards = Vector3.up);
forward는 바라보는 물체
upwards는 기본값이 Vector3.up으로 정의되있음.
Quaternion.LookRotation
static Quaternion LookRotation(Vector3 forward, Vector3 upwards = Vector3.up);
Parameters
| forward | The direction to look in. |
| upwards | The vector that defines in which direction up is. |
Description
Creates a rotation with the specified forward and upwards directions.
Returns the computed quaternion. If used to orient a Transform, the Z axis will be aligned with
forward and the Y axis withupwards if these vectors are orthogonal. Logs an error if the forward direction is zero.using UnityEngine; using System.Collections; public class Example : MonoBehaviour { public Transform target; void Update() { Vector3 relativePos = target.position - transform.position; Quaternion rotation = Quaternion.LookRotation(relativePos); transform.rotation = rotation; } }
See Also: SetLookRotation.
'유니티 > 스크립트' 카테고리의 다른 글
| 게임 매니저에서 FSM 으로 게임 분기 처리하기 (0) | 2014.02.03 |
|---|---|
| 충돌 처리시 Tag 설정 값 파악하기 (0) | 2014.02.03 |
| Quaternion.LookRotation (0) | 2014.02.03 |
| 마우스 클릭한 방향으로 스무스하게 움직이게 하기 (0) | 2014.02.02 |
| 마우스를 클릭한 방향을 바라보기 (0) | 2014.02.02 |
| [펌] 도망자 코드 3초마다 방향을 바꾸면서 도망감 (0) | 2014.02.02 |
Trackback 0 And
Comment 0


