# How do i limit the rotition speed in this script?

Hello guys. I got this script to rotate my spaceship in the direction of the mouse position. Its a 2d topdown view. Script is working but sadly the player can rotate wihtout any limitations. I want to have it the way that the ship will slowly rotate towards the mouse position since its a spaceship. Sadly i dont get how to implement it into this script.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RotateToMouse : MonoBehaviour {

public float rotationspeed = 5.0f;

void Update () {

Vector3 mouseWorldPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition + Vector3.forward * 10f);

float angle = AngleBetweenPoints(transform.position, mouseWorldPosition);

transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, angle + 90f));

}

float AngleBetweenPoints(Vector2 a, Vector2 b)
{
return Mathf.Atan2(a.y - b.y, a.x - b.x) * Mathf.Rad2Deg;
}

}

This is what i use to limit rotation with the mouse on the Y axis to 45. You need to clamp the values. You can either clamp a position on the axis for example(Position of the spaceship clamps between 0 and 100) or a rotation. In the example I give the rotation is clamped

public float minimumVert = -45.0f;
public float maxVert = 45.0f;
public float _rotationX = 0;
public float sensHorizontal = 10.0f;
public float sensVertical = 10.0f;

void Update(){
if (axes == RotationAxis.MouseY)
{
_rotationX -= Input.GetAxis("Mouse Y") * sensVertical;
_rotationX = Mathf.Clamp(_rotationX, minimumVert, maxVert);
float rotationY = transform.localEulerAngles.y;

transform.localEulerAngles = new Vector3(_rotationX, rotationY, 0);
}
}