这是我用鼠标旋转的对象的代码,但我想将其减慢到每秒18°。
这是关于二维自上而下的坦克游戏。
private Vector3 mouse_pos;
public Transform target;
private Vector3 object_pos;
private float angle;
private void Start()
{
}
void Update()
{
mouse_pos = Input.mousePosition;
mouse_pos.z = -20;
object_pos = Camera.main.WorldToScreenPoint(target.position);
mouse_pos.x = mouse_pos.x - object_pos.x;
mouse_pos.y = mouse_pos.y - object_pos.y;
angle = Mathf.Atan2(mouse_pos.y, mouse_pos.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0, 0, angle - 90);
}