using UnityEngine;

public class xuan1 : MonoBehaviour { public Transform rotationCenter; // 旋转中心点 public float rotationSpeed = 80f; // 旋转速度

private bool isRotating = false; // 是否正在旋转

private void Update()
{
    if (Input.GetMouseButtonDown(0)) // 当鼠标左键点击时
    {
        isRotating = true; // 开始旋转
    }
}

private void FixedUpdate()
{
    if (isRotating)
    {
        // 围绕旋转中心点顺时针旋转
        transform.RotateAround(rotationCenter.position, Vector3.up, rotationSpeed * Time.deltaTime);

        if (transform.rotation.eulerAngles.y >= 80) // 当物体旋转超过80度时
        {
            isRotating = false; // 停止旋转
            transform.rotation = Quaternion.Euler(0, 80, 0); // 将旋转角度设置为80度
        }
    }
}

}

Unity3D物体点击旋转:实现物体绕点顺时针旋转80度

原文地址: https://www.cveoy.top/t/topic/qkca 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录