유니티의 Transform요소 중 Rotate을 이용한 캐릭터 회전 구현
[CODE]
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RotateScript : MonoBehaviour
{
[Header("회전속도 조절")]
[SerializeField] [Range(1f, 100f)] float rotateSpeed = 50f;
void Update()
{
//회전(왼쪽회전 Z / 오른쪽회전 X)
if (Input.GetKey(KeyCode.Z))
transform.Rotate(0, 0, Time.deltaTime * rotateSpeed, Space.Self);
if (Input.GetKey(KeyCode.X))
transform.Rotate(0, 0, -Time.deltaTime * rotateSpeed, Space.Self);
}
}
댓글