Movement In A Mobile Game

So I am currently making a game that will be accessible on Pc and for Movile devices. I was wondering, how would I script the camera(character) to move left if my mouse is located on the left side and right if it’s on the right side. Hypothetically, It would be better if it detected whenever the mouse clicked. So how would I find the X location of the mouse(Y location doesn’t matter for this game)

The Input class is your answer 1

For click detection you can use GetMouseButton

Input.GetMouseButton(0)

For mouse position detection you can use mousePosition

From the Unity documentation on the Input class, this is how you detect mouse clicks:

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void Update() {
        if (Input.GetMouseButtonDown(0))
            Debug.Log("Pressed left click.");
        
        if (Input.GetMouseButtonDown(1))
            Debug.Log("Pressed right click.");
        
        if (Input.GetMouseButtonDown(2))
            Debug.Log("Pressed middle click.");
        
    }
}

And if you’re trying to determine where the mouse is, you can use Input.mousePosition (docs)

I’d recommend thoroughly researching the entire Input class and experiment a bit on your own. In order to determine a “left/right” you’ll need to know the screen resolution.

You could also create GUI elements on the left/right sides of the screen, make them invisible, and add OnClick listeners.