Plane rotation as in War Thunder


so I’m trying to create a plane rotating system based on the war thunder’s one. So I have a mouse position and all I have to do is put an object infront of the plane with that mouse position, so the plane can rotate towards it. I’ve set camera to follow plane, but I found out there is a problem when I try to rotate the plane itself.

So I’m trying to have the cube placed as on picture below:

But here is what happens when I rotate it: Screenshot by Lightshot

Cube just gets to close to the plane, even if I’ve set offset to be in forward direction of it.

Here is my code:
using UnityEngine;

public class Player_Plane_Controller : MonoBehaviour
float mouseX;
float mouseY;

Vector3 position;
Vector3 positionMouse;

Vector3 dir;
Quaternion toRotation;

public GameObject a;

private void Update()
    positionMouse = Input.mousePosition;
    positionMouse.z = 0;

    position = Camera.main.ScreenToWorldPoint(positionMouse + transform.forward * 20.0f);
    a.transform.position = position;

    dir = a.transform.position - transform.position;
    toRotation = Quaternion.FromToRotation(transform.forward, dir);
    transform.rotation = Quaternion.Lerp(transform.rotation, toRotation, Time.deltaTime * 2);*/


So what I want is the cube to be at the same distance, no matter the rotation, but still use mouse location.
I’m kinda really stuck, tried to use different approach for like 5 times now, so any help would be appreciated.

However I did find somekind of thread made for war thunders mouse system, but it wasn’t really answered.

Thank you for your time.

So I replaced Update code with this:

mouseInput = Input.mousePosition;
mouseInput.z = 20.0f;

    position = Camera.main.ScreenToWorldPoint(mouseInput);

    aimPos = position;

    dir = aimPos - transform.position;
    toRotation = Quaternion.LookRotation(dir);
    Quaternion startRotation = transform.rotation;

    if (Vector3.Distance(aim.transform.position, aim2.transform.position) > 5.1f)
        transform.rotation = Quaternion.Slerp(transform.rotation, toRotation, Time.deltaTime * 2);

    aim.transform.position = aimPos;
    aim2.transform.position = transform.forward * 15.0f;


This works, however the plane wont rotate for full 360 degrees around x (local x of plane, not world x), instead it starts flickering before it reaches +90 or -90 degrees on x. Any help would be welcome.