gif效果图如下:
以下脚本直接挂载在需要转动的人物身上即可。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerRotate : MonoBehaviour
{
private float x_axle = 0;
private float y_axle = 0;
private void RotateObj()
{
if (Input.GetMouseButton(0))
{
x_axle = Input.GetAxis("Mouse X");
y_axle = Input.GetAxis("Mouse Y");
}
if (x_axle > 0)
{
x_axle -= Time.deltaTime;
if (x_axle < 0)
x_axle = 0;
}
else
{
x_axle += Time.deltaTime;
if (x_axle > 0)
x_axle = 0;
}
if (y_axle > 0)
{
y_axle -= Time.deltaTime;
if (y_axle <