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 = 프리팹이 이동될 이동 벡터(방향)
반응형
'유니티 C# 함수 사용 정리' 카테고리의 다른 글
[LINQ] 확장 메서드 (0) | 2024.05.09 |
---|---|
Resources 폴더에서 Atlas를 찾아 image 반환하기 (0) | 2024.03.25 |
충돌된 지점의 법선 벡터 메모 (0) | 2024.03.14 |
딕셔너리와 인덱서 (0) | 2024.02.08 |
대리자(delegate) (0) | 2024.01.30 |