How to change mouselook axes option via script.

Hello everyone! Kinda late so if i sound a bit rude i apologize. I do not mean to!
:slight_smile:

I was wondering if there was a way to change the axes of mouselook via script.

So if my player collides with a trigger zone, it’ll change his mouselook axes from MouseX to MouseY && MouseX.

Thank you for reading!
Sincerely,

Bakos

using UnityEngine;
using System.Collections;

public class InputAxis : MonoBehaviour 
{
	public bool xAxis = true;
    private float mouseX=0f;
    private float mouseY=0f;
    public float X_MouseSensitivity=5f; //x movement sensitivity
public float Y_MouseSensitivity=5f; //y movement sensitivity
	void Start () 
	{
		xAxis=true;
	}
	
	void Update () 
	{
		if(xAxis)
		{
			mouseX+=Input.GetAxis("Mouse X")*X_MouseSensitivity;
		}
		else
		{
			mouseX+=Input.GetAxis("Mouse X")*X_MouseSensitivity;
		    mouseY-=Input.GetAxis("Mouse Y")*Y_MouseSensitivity;
		}
            
	}

	void OnTriggerEnter (Collider col)
	{
		xAxis=false;
	}
	void OnTriggerExit (Collider col)
	{
		xAxis=true;
	}

}