普通旋转
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Rotate : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.Rotate(new Vector3(1, 0, 0)); //绕x轴旋转
transform.Rotate(new Vector3(0, 1, 0)); //绕y轴旋转
transform.Rotate(new Vector3(0, 0, 1)); //绕z轴旋转
}
}
调整旋转速度
可以通过调整speed来调整旋转速度
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Rotate : MonoBehaviour
{
public int speed = 90;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.Rotate(new Vector3(speed * Time.deltaTime, 0, 0)); //绕x轴旋转
transform.Rotate(new Vector3(0, speed * Time.deltaTime, 0)); //绕y轴旋转
transform.Rotate(new Vector3(0, 0, speed * Time.deltaTime)); //绕z轴旋转
}
}