首页 > 编程知识 正文

unity物体绕自身y轴旋转,unity3d控制物体旋转

时间:2023-05-06 08:55:18 阅读:200090 作者:1737

普通旋转 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轴旋转 }}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。