https://docs.unity3d.com/ScriptReference/Quaternion.LookRotation.html

 

Unity - Scripting API: Quaternion.LookRotation

Z axis will be aligned with forward, X axis aligned with cross product between forward and upwards, and Y axis aligned with cross product between Z and X. Returns identity if the magnitude of forward is zero. If forward and upwards are colinear, or if the

docs.unity3d.com

 

 

 

GameObject prefab = Instantiate(original_prefab, position, Quaternion.LookRotation(Vector3.forward, dirVec));

 

 

original_prefab = 생성할 게임 오브젝트(프리팹)

 

position = 생성될 위치

 

Quaternion.LookRotation(Vector3.forward, dirVec) = Vector3.forward의 방향을 dirVec 의 방향으로 회전

    Vector3.forward = 프리팹의 앞쪽

    dirVec = 프리팹이 이동될 이동 벡터(방향)

반응형

+ Recent posts