Unity
[Unity] RotateAround()를 이용한 빙글빙글 돌기
FiveReptile
2020. 4. 12. 22:19
728x90
RotateAround()라는 함수를 사용하여 빙글빙글 도는 움직임을 만들어보겠습니다.
Transform.RotateAround(Vector3 point, Vector3 axis, float angle)
- point = 기준점
- axis = 움직이는 방향(대략적인 설명이다.)
- angle = 움직이는 속도
movement = 움직이는 방향에 대한 정보를 저장하는 변수이다.
moveSpeed = 움직이는 속도에 대한 정보를 저장하는 변수이다.
Update()는 OnMove() 함수를 호출한다.
FixedUpdate()는 transform.RoateAround(Vector3.zero, Vector3.back, movement * Time.fixedDeltaTime * moveSpeed);를 사용하여 (0,0,0)을 기준으로 Vector3.back 축을 기준으로 movement * Time.fixedDeltaTime * moveSpeed의 속도로 움직인다.
OnMove()는 수평축 입력에 대한 정보를 movement에 전해준다.
728x90