第一种:
transform.Rotate(new Vector3(90, 0, 0));
//重载方式重载方式一 第一个参数是 x轴 旋转度数,第二个参数是 Y 轴 旋转度数 ,第三个参数是Z轴旋转度数 ,
//第四个参数是自身还是世界坐标
public void Rotate(float xAngle, float yAngle, float zAngle, Space relativeTo = Space.Self);
//重载方式二 第一个参数沿着谁旋转 第二个参数是旋转的角度 第三个参数是自身还是世界坐标
public void Rotate(Vector3 axis, float angle, Space relativeTo = Space.Self);
// 重载方式三 第一个参数沿着谁旋转 第二个参数是沿着自身还是世界坐标 一般的默认世界旋转
public void Rotate(Vector3 eulers, Space relativeTo = Space.Self);
using UnityEngine;
public class ExampleClass : MonoBehaviour
{
public float speed; // 速度
void Update()
{
//以每秒1度的速度围绕其局部X轴旋转对象
transform.Rotate(Vector3.right * Time.deltaTime*speed);
// 以世界坐标的Y 轴进行旋转
transform.Rotate(Vector3.up * Time.deltaTime, Space.World*speed);
}
}
第二种: 四元数旋转
transform.rotation = Quaternion.Euler(45, 45, 45);
// 重载方式是一个参