角度和旋转

public class Lesson7 : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        #region 角度
        //相对世界坐标角度
        print(transform.eulerAngles);

        //相对父坐标角度
        print(transform.localEulerAngles);

        //与位置相似,不能直接对x,y,z单独赋值
        //得到的欧拉角没有负数只有0~360
        #endregion
    }

    // Update is called once per frame
    void Update()
    {
        #region 旋转
        //API调用
        //自转
        //第一个参数是每帧旋转的角度
        //第二个参数是坐标系选取
        transform.Rotate(new Vector3(0,10,0)*Time.deltaTime,Space.World);
        //相对于某个轴自转
        //第一个参数是相对于哪个轴转动
        //第二个参数是每一帧转动的角度
        //第三个参数是坐标轴选取
        transform.Rotate(Vector3.up, 10*Time.deltaTime,Space.World);

        //相对于某一个点转
        //第一个参数公转中心
        //第二个参数是旋转轴
        //第三个参数是每帧旋转的角度
        transform.RotateAround(Vector3.zero, Vector3.up,10*Time.deltaTime);
        #endregion
    }
}
posted @ 2025-03-15 20:55  cannedmint  阅读(10)  评论(0)    收藏  举报