Android input is not working on build.. it freezes the game on mobile(after installation) and on editor when input is given through mobile using with unity remote

Android input is not working on build… it freezes the game on mobile(after installation) and on editor when input is given through mobile using with unity remote… It was working perfectly on unity remote before first built was made… now it there is a problem …
The game is not even receiving input from buttons of UI …
My code for input system looks like this :
void Update()
{
#if UNITY_EDITOR || UNITY_STANDALONE || UNITY_WEBPLAYER
float horizontalMovement = Input.GetAxis(“Horizontal”);
transform.position = Vector3.Lerp(gameObject.transform.position, new Vector3(Mathf.Clamp(gameObject.transform.position.x + horizontalMovement, -2.5f, 2.5f), gameObject.transform.position.y, gameObject.transform.position.z), directionalSpeed * Time.deltaTime);
#endif
rb.velocity = Vector3.forward * playerSpeed * Time.deltaTime;
transform.Rotate(Vector3.right * GetComponent().velocity.z/2);

    // Mobile Controls
    Vector2 touch = Camera.main.ScreenToWorldPoint(Input.mousePosition + new Vector3(0, 0, 10f));
    if (Input.touchCount > 0)
    {
        Debug.Log("Touch detected! Touch count: " + Input.touchCount);
        Vector3 a = new Vector3(border1.transform.position.x, border1.transform.position.y, border1.transform.position.z);
        Vector3 b = new Vector3(border2.transform.position.x, border2.transform.position.y, border2.transform.position.z);
        Vector3 c = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z);
        while (Vector3.Distance(a, c) != 0 && Vector3.Distance(b, c) != 0)
            transform.position = new Vector3(touch.x, transform.position.y, transform.position.z);
        if (Vector3.Distance(a, c) == 0)
        {
            transform.position = new Vector3(-0.5f, transform.position.y, transform.position.z);
            playerSpeed -= 50;
        }

        else if (Vector3.Distance(b, c) == 0)
        {
            transform.position = new Vector3(0.5f, transform.position.y, transform.position.z);
            playerSpeed -= 50;
        }
        }

,Android input is not working on build… it freezes the game on mobile(after installation) and on editor when input is given through mobile using with unity remote… It was working perfectly on unity remote before first built was made… now it there is a problem … My code for input system looks like this :
void Update()
{
#if UNITY_EDITOR || UNITY_STANDALONE || UNITY_WEBPLAYER
float horizontalMovement = Input.GetAxis(“Horizontal”);
transform.position = Vector3.Lerp(gameObject.transform.position, new Vector3(Mathf.Clamp(gameObject.transform.position.x + horizontalMovement, -2.5f, 2.5f), gameObject.transform.position.y, gameObject.transform.position.z), directionalSpeed * Time.deltaTime);
#endif
rb.velocity = Vector3.forward * playerSpeed * Time.deltaTime;
transform.Rotate(Vector3.right * GetComponent().velocity.z/2);

    // Mobile Controls
    Vector2 touch = Camera.main.ScreenToWorldPoint(Input.mousePosition + new Vector3(0, 0, 10f));
    if (Input.touchCount > 0)
    {
        Debug.Log("Touch detected! Touch count: " + Input.touchCount);
        Vector3 a = new Vector3(border1.transform.position.x, border1.transform.position.y, border1.transform.position.z);
        Vector3 b = new Vector3(border2.transform.position.x, border2.transform.position.y, border2.transform.position.z);
        Vector3 c = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z);
        while (Vector3.Distance(a, c) != 0 && Vector3.Distance(b, c) != 0)
            transform.position = new Vector3(touch.x, transform.position.y, transform.position.z);
        if (Vector3.Distance(a, c) == 0)
        {
            transform.position = new Vector3(-0.5f, transform.position.y, transform.position.z);
            playerSpeed -= 50;
        }

        else if (Vector3.Distance(b, c) == 0)
        {
            transform.position = new Vector3(0.5f, transform.position.y, transform.position.z);
            playerSpeed -= 50;
        }
        }

@mysticlover - I’m really sorry for the delay I seem to be the only active moderator these days, I’m trying my best to keep up, but this is volunteered time.

Let’s troubleshoot the issue step-by-step.

Step 1: Check the Android version and Android device you are using. Unity Remote 5 is known to have issues with some Android versions or specific devices. It is recommended to use a device running Android 5.0 (Lollipop) or later for better compatibility.

Step 2: If the issue persists, there may be a problem with the input handling code in your script. Here is the code snippet you posted:

void Update() 
{
    #if UNITY_EDITOR || UNITY_STANDALONE || UNITY_WEBPLAYER
        float horizontalMovement = Input.GetAxis("Horizontal");
        transform.position = Vector3.Lerp(gameObject.transform.position, 
            new Vector3(Mathf.Clamp(gameObject.transform.position.x + horizontalMovement, -2.5f, 2.5f), 
            gameObject.transform.position.y, gameObject.transform.position.z), 
            directionalSpeed * Time.deltaTime);
    #endif
    rb.velocity = Vector3.forward * playerSpeed * Time.deltaTime;
    transform.Rotate(Vector3.right * GetComponent<Rigidbody>().velocity.z/2);
  
    // Mobile Controls
    Vector2 touch = Camera.main.ScreenToWorldPoint(Input.mousePosition + new Vector3(0, 0, 10f));
    if (Input.touchCount > 0)
    {
        Debug.Log("Touch detected! Touch count: " + Input.touchCount);
        Vector3 a = new Vector3(border1.transform.position.x, border1.transform.position.y, border1.transform.position.z);
        Vector3 b = new Vector3(border2.transform.position.x, border2.transform.position.y, border2.transform.position.z);
        Vector3 c = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z);
        while (Vector3.Distance(a, c) != 0 && Vector3.Distance(b, c) != 0)
            transform.position = new Vector3(touch.x, transform.position.y, transform.position.z);
        if (Vector3.Distance(a, c) == 0)
        {
            transform.position = new Vector3(-0.5f, transform.position.y, transform.position.z);
            playerSpeed -= 50;
        }
        else if (Vector3.Distance(b, c) == 0)
        {
            transform.position = new Vector3(0.5f, transform.position.y, transform.position.z);
            playerSpeed -= 50;
        }
    }
}

Please make sure you use Input.touches for mobile touch input instead of Input.mousePosition. The latter is for mouse controls on PC. Try replacing this:

Vector2 touch = Camera.main.ScreenToWorldPoint(Input.mousePosition + new Vector3(0, 0, 10f));

with this:

if (Input.touchCount > 0) 
{
    Touch touch = Input.GetTouch(0);
    Vector2 touchPosition = Camera.main.ScreenToWorldPoint(touch.position);
    // Use 'touchPosition' in the rest of your code
}

Step 3: Remember that ScreenToWorldPoint returns a position in world space, not in screen space. This may result in issues if you’re not careful. Always be sure that you’re working in the right coordinate space.

Step 4: If your game is not receiving input from UI buttons, check your Event System and Canvas components. Make sure the Event System is properly set up and that your Canvas is in Screen Space - Overlay render mode unless you have a good reason to use a different mode.

Let me know if this gets you closer to an answer.