using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Rotate : MonoBehaviour {
private Transform m_transform;
// Use this for initialization
void Start () {
m_transform = gameObject.GetComponent<Transform>();
}
// Update is called once per frame
void Update () {
if (Input.GetKey(KeyCode.Q)) {
m_transform.Rotate(Vector3.down * 10 * Time.deltaTime);
}
if (Input.GetKey(KeyCode.E)) {
m_transform.Rotate(Vector3.up * 10 * Time.deltaTime);
}
}
}
Unity3D学习记录——物体旋转
最新推荐文章于 2024-07-10 17:13:46 发布
本文介绍了一个简单的Unity脚本,用于控制游戏对象围绕垂直轴进行旋转。通过键盘按键Q和E,可以分别实现逆时针和顺时针旋转。该脚本使用了Unity的Transform组件和Input系统。
506

被折叠的 条评论
为什么被折叠?



