unity api part 1 05 translating a box from Walker Boys on Vimeo.

이번 동영상은 translate 메서드를 통해 만들어 놓은 Cube 오브젝트를 이동시키는 것을 설명합니다. translate 메서드를 검색해 보시면...

Transform.Translate  

function Translate (translation : Vector3, relativeTo : Space = Space.Self) : void

Description

Moves the transform in the direction and distance of translation.

이라고 나옵니다. 즉, position, rotation, and scale 정보를 가진 transform을 주어진 방향으로 이동시키는 역할을 하는 것입니다. 동영상에서도 나오지만 적당한 값을 넣으면 그 방향으로 계속해서 이동하는 것을 보게 됩니다.

transform.Translate(fBoxSpeed * Time.deltaTime, 0, 0);

위의 소스는 Vector x의 방향으로 fBoxSpeed만큼의 속도에 Time.deltaTime의 시간값을 곱해서 이동을 시킵니다. Time.deltaTime에 대해 궁금하시다면 Reference를 찾아보시면 상세하게 설명이 되어있습니다. 친절하게 아래에 Copy&Paste를 했습니다!

Description

The time in seconds it took to complete the last frame (Read Only).

If you add or subtract to a value every frame chances are you should multiply with Time.deltaTime. When you multiply withTime.deltaTime you essentially express: I want to move this object 10 meters per second instead of 10 meters per frame.


Posted by hp-david
,