using UnityEngine;
public class Cube : MonoBehaviour
{
public float degreePerScend = 40.0f;
public Transform targetPos;
void Update()
{
this.gameObject.transform.Rotate( Vector3.up * Time.deltaTime * this.degreePerScend);
// 절대적인 회전 각도로 회전
this.gameObject.transform.Rotate(Vector3.up * Time.deltaTime * this.degreePerScend, Space.World);
// 자신 기준
this.gameObject.transform.Rotate(Vector3.up * Time.deltaTime * this.degreePerScend, Space.Self);
// Vector3.left / right - X 축
// Vector3.up / down - Y축
// Vector3.back / forward - Z축
}
}
직접 각도를 입력
using UnityEngine;
public class Cube : MonoBehaviour
{
void Start()
{
// 절대적인 각도
this.gameObject.transform.Rotate(20f, 50f, 100f, Space.World);
// 자신 기준
this.gameObject.transform.Rotate(20f, 50f, 100f, Space.Self);
}
}
Transform.RotateAround 특정 좌표를 기준으로 게임오브젝트를 회전
using UnityEngine;
public class CubeZ : MonoBehaviour
{
public Transform Target;
public float degreePerSpeed = 20.0f;
void Update()
{
this.gameObject.transform.RotateAround(Target.position, Vector3.forward, Time.deltaTime * this.degreePerSpeed);
}
}