728x90
Quaternion & Quaternion.Euler
transform.rotation์ Quaternionํํ์ธ (x, y, z, w)์ ํํ๋ก ํ์๋๋ค.
Quaternion.Euler์ Vector3 ๊ฐ์ ๋ฃ์ผ๋ฉด Quaternion ๊ฐ์ผ๋ก ๋ณํ๋๋ค.
transfomr.rotation = Quaternion.Euler(new Vector3(30,50,20));
transform.rotation = Quaternion.Euler(30,50,20); // ์์ ๋์ผ
๊ฐ๋ ๋ํ๊ธฐ
1. Vector3 ๊ฐ์ผ๋ก ๋ณํ ํ ๋ํ ๋ค์ Quaternion์ผ๋ก ๋ค์ ๋ณํ.
Quaternion originalRot = transform.rotation;
Vector3 originalRotVec3 = originalRot.eulerAngles;
Vector3 newRotation = originalRotVec3 + new Vector3(10, 50, 20);
transform.rotation = Quaternion.Euler(newRotation);
2. Quaternion ๊ฐ ๋ํ๊ธฐ(=๊ณฑํ๊ธฐ)
Quaternion originalRot = Quaternion.Euler(new Vector3(5, 20, 40));
Quaternion addRot = Quaternion.Euler(new Vector3(25, 10 ,5));
Quaternion newRot = originRot * addRot; //๊ณฑํ๊ธฐ๊ฐ ํฉ์ ์๋ฏธ
transform.rotation = newRot;
728x90
'Unity > Unity(๊ธฐ์ด)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Unity ๋์ ์์ฑ์ Random.Range๋ฅผ ํ์ฉํ์ (0) | 2021.08.17 |
---|---|
unity ์ํ์ข์ฐ ์ฝ๋ 2๊ฐ์ง Input.GetKey vs Input.GetAxis ๊ทธ๋ฆฌ๊ณ Translate() ํจ์์ ํ์ฉ (0) | 2021.08.12 |
[์ ๋ํฐ] get set ํ๋กํผํฐ Property(์์ฑ) (0) | 2021.05.23 |
[์ ๋ํฐ] Debug.Log์ Debug.LogFormat ํ์ฉ. ์ด๋ค ๊ฒ์ ์จ์ผํ ๊น? (0) | 2021.05.22 |
์ ๋ํฐ ์ฝ๋ฃจํด Coroutine (0) | 2021.05.19 |