[Unity3D] 이동, 회전, 크기변경 정리
UnityUnity에서 GameObject의 이동, 회전, 크기변경을 하기 위한 방법에 대해 알아보자.
- 이동
|
1
|
transform.position = new Vector3(x, y, z);
|
|
1
|
transform.Translate(speed, 0, 0);
|
|
1
|
transform.position = Vector3.MoveTowards(transform.position, target.position, speed);
|
taget 오브젝트에게 일정하게 이동하고 싶다면 위와같이 MoveToward를 쓰면 된다.
- 회전
|
1
|
transform.rotation = Quaternion.identity;
|
|
1
|
transform.Rotate(Vector3.up, speed, Space.World);
|
|
1
|
transform.LookAt(target)
|
|
1
|
transform.rotation = Quaternion.RotateTowards(transform.rotation, lookRotation, speed);
|
|
1
|
transform.localScale = new Vector3(1, 1, 1);
|
|
1
|
transform.localScale += new Vector3(1, 0, 0);
|
|
1
|
float speed = 10 * Time.deltaTime;
|
'Unity' 카테고리의 다른 글
| [Unity3D] WWW객체로 Web에 있는 Image 불러오기 (0) | 2015.12.07 |
|---|---|
| [Unity3D] Coroutine (0) | 2015.11.28 |
| [Unity3D] GameObject 생성과 삭제. Instantiate와 Destroy (1) | 2015.11.23 |
| [Unity3D] Prefab (0) | 2015.11.20 |
| [Unity3D] 충돌처리. Trigger와 Collision (2) | 2015.11.20 |