# Is it possible to work out rotate in degrees per second based on this rotate logic?

I have this code to rotate an object towards another at a given speed.

    /// <summary>
/// Rotate towards the target.
/// </summary>
/// <param name="lookPosition"></param>
private void RotateTowardsTarget(Vector3 lookPosition)
{
// Determine which direction to rotate towards
Vector3 targetDirection = lookPosition - transform.position;

// The step size is equal to speed times frame time.
float singleStep = weaponRotationSpeed * Time.deltaTime;

// Rotate the forward vector towards the target direction by one step
Vector3 newDirection =
Vector3.RotateTowards(turretYRotation.transform.forward, targetDirection, singleStep, 0.0f);

// Draw a ray pointing at our target in
//Debug.DrawRay(turretYRotation.transform.position, newDirection, Color.red, 3);

newDirection.y = 0;
// Calculate a rotation a step closer to the target and applies rotation to this object
turretYRotation.transform.rotation = Quaternion.LookRotation(newDirection);
}


And I'd like to convert this to a "Degrees per second" to give the user useful feedback on how quickly it rotates. Is there a formulae I can apply to work it out?

• Do you want weaponRotationSpeed to be in degrees per second, or do you want to return how fast it is rotating? – bornander Jun 8 at 20:41

Currently weaponRotationSpeed defines the rotation speed in radians per second, if what you're asking is to let this variable define rotation speed in degrees per second you should change
float singleStep = weaponRotationSpeed * Time.deltaTime;

float singleStep = (weaponRotationSpeed * (180/Math.PI)) * Time.deltaTime;

• Not quite, what I'd like tot do is leave the rotation code as it is, but have a way to work of "Given weaponRotationSpeed is X, that means the turret is rotating at Y degress a second", so I can display that to the user – TMH Jun 4 at 16:59