Gameobject rotation differs between display/monitors

I’m facing a problem when I’m rotating a gameobject 90 degrees. When I have my unity editor or my compiled game on my primary screen. The cube only rotates, what it looks like, 45 degrees. But in the inspector the gameobjects z rotation is 90 degrees.

When I have my game running or unity editor on my secondary screen it works as intended and rotates my cube 90 degrees.

I can’t seem to find the cause of why the game behaves like this. Anyone know what i’m doing wrong?


Primary monitor. Rotation not working


Secondary monitor. Rotation working

My player controller for rotation

using UnityEngine;
using UnityEngine.Events;
 
public class playercontroller : MonoBehaviour
{
 
    [SerializeField]
 
    [Header("Smash  event")]
    public UnityEvent smashEvent;
 
    private float speed = 3.500f;
    private bool rotating = false;
 
    float currentRotationAngle = 0f;
    float targetRotationAngle = 90f;
 
    Vector3 rotationAxis = new Vector3(0f, 0f, 0f);
 
    private bool smashing = false;
 
 
    // Start is called before the first frame update
    void Start()
    {
        if (smashEvent == null)
        {
            smashEvent = new UnityEvent();
        }
    }
 
 
    void OnDrawGizmos()
    {
    }
 
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.W) && !rotating)
        {
            print("w");
            rotationAxis = new Vector3(0f, 0f, 1f);
            rotating = true;
        }
        else if (Input.GetKeyDown(KeyCode.S) && !rotating)
        {
            print("S");
            rotationAxis = new Vector3(0f, 0f, -1f);
            rotating = true;
        }
        else if (Input.GetKeyDown(KeyCode.A) && !rotating)
        {
            print("A");
            rotationAxis = new Vector3(0f, 1f, 0f);
            rotating = true;
        }
        else if (Input.GetKeyDown(KeyCode.D) && !rotating)
        {
            print("D");
            rotationAxis = new Vector3(0f, -1f, 0f);
            rotating = true;
        }
        else if (Input.GetKeyDown(KeyCode.R))
        {
        }
        else if (Input.GetKeyDown(KeyCode.Space))
        {
            print("dispathc");
            smashEvent.Invoke();
        }
 
 
        if (rotating)
        {
            var angle = Mathf.LerpAngle(0, targetRotationAngle, speed * Time.deltaTime);
            var nextAngle = Mathf.Abs(currentRotationAngle + angle);
 
            if (nextAngle > targetRotationAngle)
            {
                var lastRotation = Mathf.Abs(currentRotationAngle - targetRotationAngle);
                transform.Rotate(rotationAxis, lastRotation, Space.World);
                rotating = false;
                currentRotationAngle = 0f;
            }
            else
            {
                transform.Rotate(rotationAxis, angle, Space.World);
                currentRotationAngle = currentRotationAngle + angle;
            }
        }
    }
}

,

I solved it by locking the fps to 60 fps.