MouseLook script 90 degrees off

I’m using a standard mouselook script to point a cannon object at the mouse cursor. However, the cannon seems to always point 90 degrees to the right or left (depending upon which reference plane I build in the script). I can’t figure out why it would do this, so any help would be appreciated.

Here is what I’m seeing from the cannon (red diamond represents the mouse cursor):

I’ve taken a standard script from here and lightly adapted it. However, there is one key difference between the classic example of this and mine: the plane upon which my items rest is that my plane is on XY, rather than XZ. This is illustrated below:

Finally, here is the code:

void Update () 
		Plane playerPlane = new Plane(Vector3.forward, transform.position);
		Ray hitRay = Camera.main.ScreenPointToRay(Input.mousePosition);
		float hitDist = 0.0f;
		if(playerPlane.Raycast(hitRay,out hitDist))
			Vector3 targetPoint = hitRay.GetPoint(hitDist);
			Quaternion targetRotation = Quaternion.LookRotation(targetPoint - transform.position);
			transform.rotation = Quaternion.Slerp(transform.rotation,targetRotation, 1); 

Any help would be much appreciated.

the normal for the plane shouldnt be forward if your game lies on the forward plane.

what this code does is create a plane. That plane contains a point and has a normal that define it.

look at rotates from the objects current forward to a new rotation which have the forward pointing towards a point in space.

however since forward is the normal of the plane its going to be wanky.

I THINK you need to change it to vector3.up perhaps to get the right plane.

Appears so.

Is your canon initially aligned to face the z direction (forward)? the blue gizmo arrow should run through the barrel of the cannon towards the barrel mouth.