Moving Camera Issue

I’ll Just explain how my controls are set up first:

Im making a Game where you walk forwards and backwords with W and S.
The mouse look for the X axis is set up with A and D
So for Y axis Mouse look I added an
if (Input.GetMouseButton (0))
{
}
to the regular Mouse look script and renamed it for Y Axis Purpose only. So When I click the Screen And drag the camera will look up and down. aka “Panning”
I have mouse look script on my character for X Axis
and the second mouse look script on the Main Camera for Y Axis.

Everything works fine, the A and D rotates the screen, The Panning works only when I click it all works great.

The Problem Im having is when my mouse is on the left hand of the screen and I attempt to pan, the camera moves its position from the character to the left.

So when I start Say its like this:

…Camera
…Character

Then The Camera Moves only when My mouse is on the left side of the screen to something like this:

Camera
…Character

So it is no longer in line with my character. it is very fustrating and cant seem to figure it out. Taking any suggestions…

I hope this is explained in a way you can understand, if not please ask and ill do my best to describe the situation.

Here is the “Panning” Script I use:

using UnityEngine;

[AddComponentMenu("Camera/Simple Smooth Mouse Look Camera")]
public class SimpleSmoothMouseLookCamera : MonoBehaviour
{
    Vector2 _mouseAbsolute;
    Vector2 _smoothMouse;

    public Vector2 clampInDegrees = new Vector2(360, 180);
    public bool lockCursor;
    public Vector2 sensitivity = new Vector2(2, 2);
    public Vector2 smoothing = new Vector2(3, 3);
    public Vector2 targetDirection;
    public Vector2 targetCharacterDirection;
    public GameObject characterBody;

    void Start()
    {
        targetDirection = transform.localRotation.eulerAngles;

        if (characterBody) targetCharacterDirection = characterBody.transform.localRotation.eulerAngles;
    }

    void Update()
    {
        if (Input.GetMouseButton (0))
        {
    
            var targetOrientation = Quaternion.Euler (targetDirection);
            var targetCharacterOrientation = Quaternion.Euler (targetCharacterDirection);
            var mouseDelta = new Vector2 (Input.GetAxisRaw ("Horizontal"), Input.GetAxisRaw ("Mouse Y"));

            mouseDelta = Vector2.Scale (mouseDelta, new Vector2 (sensitivity.x * smoothing.x, sensitivity.y * smoothing.y));
//            _smoothMouse.x = Mathf.Lerp (_smoothMouse.x, mouseDelta.x, 1f / smoothing.x);
            _smoothMouse.y = Mathf.Lerp (_smoothMouse.y, mouseDelta.y, 1f / smoothing.y);
            _mouseAbsolute += _smoothMouse;

//            if (clampInDegrees.x < 360)
//                _mouseAbsolute.x = Mathf.Clamp (_mouseAbsolute.x, -clampInDegrees.x * 0.5f, clampInDegrees.x * 0.5f);
        
            var xRotation = Quaternion.AngleAxis (-_mouseAbsolute.y, targetOrientation * Vector3.right);
            transform.localRotation = xRotation;

            if (clampInDegrees.y < 360)
                _mouseAbsolute.y = Mathf.Clamp (_mouseAbsolute.y, -clampInDegrees.y * 0.5f, clampInDegrees.y * 0.5f);
        
            transform.localRotation *= targetOrientation;

            if (characterBody) {
                var yRotation = Quaternion.AngleAxis (_mouseAbsolute.x, characterBody.transform.up);
                characterBody.transform.localRotation = yRotation;
                characterBody.transform.localRotation *= targetCharacterOrientation;
            } else {
                var yRotation = Quaternion.AngleAxis (_mouseAbsolute.x, transform.InverseTransformDirection (Vector3.up));
                transform.localRotation *= yRotation;
            }
        }
    }
}

Solved it, after hours of trouble shooting… simple mistake…

I had my networkmanager turning the script on when connected, but forgot to turn the script off on the character