Unity - PlayerController
- 플레이어의 입력 키 값을 받아 플레이어 캐릭터를 움직이게 하는 스크립트 컴포넌트이다.
- Update문에 input.getKey 등의 함수를 이용해 플레이어의 키 입력에 따른 플레이어 캐릭터의 움직임을 구현한다.
- 이 때 Update문은 프레임만큼 실행되기 때문에 Time.DeltaTime을 곱하여 움직임이 초단위로 계산되도록 구현한다.
- Speed값을 따로 정의하여 추가로 곱해주어 속도를 조절하도록 구현도 가능하다. 이 때 Speed를 Public으로 정의하거나 [SerializeField]를 추가하면 에디터 내에서 수정이 가능하다.
Vector3.forward
transform.forward
transform.TransformDirection();
transform.InverseTransformDirection();
transform.Translate();
transform.position.magnitude;
transform.position.normalized;
Rotation
transform.eulerAngles = new Vector3(0.0f, _yAngle, 0.0f);
transform.Rotate(new Vector3(0.0f, Time.deltaTime * 100.0f, 0.0f));
transform.rotation = Quaternion.Euler(new Vector3(0.0f,_yAngle,0.0f));
Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(Vector3.forward),0.1f);
Scale