I'm having an issue with a player being able to rotate on Pc but not Android

I’m having an issue with a player (paddle) being able to rotate on PC as intended but when I make a build for android it doesn’t allow the player to do so. I haven’t seen any errors in the script, and the Debug logs on both PC and Android Debugger show no errors. I’m not sure what could be the cause.

The only area that controls and affects the rotation is in the MovePaddle() method, I believe x.X.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Paddle : MonoBehaviour
{
    public float paddleSpeed;

    Rigidbody rb;
    public static Paddle Instance { get; private set; }
    public static int coinsInGame;
    private float screenWidth;

    float smooth = 5.0f;
    float tiltAngle = 60.0f;

    public GameObject hazardHitFx;
   

    // Start is called before the first frame update
    void Start()
    {       
        Instance = this;
        rb = GetComponent<Rigidbody>();
        screenWidth = Screen.width;
        rb.constraints = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
    }

    // Update is called once per frame
    void Update()
    {       

        if (SystemInfo.deviceType == DeviceType.Handheld)
        {
            int i = 0;
           
            while (i < Input.touchCount)
            {
                if (Input.GetTouch(i).position.x > screenWidth / 2)
                {
                    MovePaddle(100f);
                }
                if (Input.GetTouch(i).position.x < screenWidth / 2)
                {
                    MovePaddle(-100f);
                }
                ++i;
            }
        }
        else
        {
            if (!Input.anyKey)
            {
                MovePaddle(0f);
                paddleSpeed = 0f;
            }
            if (Input.GetKey("a"))
            {
                paddleSpeed = 50f;
                MovePaddle(-100f);
            }
            if (Input.GetKey("d"))
            {
                paddleSpeed = 50f;
                MovePaddle(100f);
            }
           
        }
    }

    void FixedUpdate()
    {
    #if UNITY_EDITOR
        MovePaddle(Input.GetAxis("Horizontal"));
    #endif
    }   

    public void MovePaddle(float horizontalInput)
    {       
        //move left and right
        rb.AddForce(new Vector3(horizontalInput * paddleSpeed * Time.deltaTime, 0, 0));
        //check the debug on the android device..
        //Debug.Log(horizontalInput);
        float tiltAroundX = Input.GetAxis("Horizontal") * tiltAngle / 2.5f;

        // Rotate the player by converting the angles into a quaternion.
        Quaternion target = Quaternion.Euler(tiltAroundX, 90, 0);
       
        // Dampen towards the target rotation
        rb.transform.rotation = Quaternion.Slerp(rb.transform.rotation, target, Time.deltaTime * smooth);
               
    }

    //collide with coins or other drops..
    void OnCollisionEnter(Collision collision)
    {
        //Debug.Log("Coins");
        if (collision.gameObject.tag == "Coins")
        {
            GameManager.Instance.Coins += 100;

            if (GameManager.Instance.isCoinBall == true)
            {
                GameManager.Instance.Coins += 100;
            }
            Destroy(collision.gameObject);
        }
        if (collision.gameObject.tag == "Hazard")
        {
            if(GameManager.Instance.isEdgePaddle == false)
            {
                StartCoroutine(Freeze());
            }               
            Destroy(collision.gameObject);
        }

    }

    IEnumerator Freeze()
    {
        Instantiate(hazardHitFx, transform.position, Quaternion.identity);
        rb.constraints = RigidbodyConstraints.FreezePosition | RigidbodyConstraints.FreezeRotation;
        paddleSpeed = 0;
        GameManager.Instance.FlashFreeze();
        yield return new WaitForSeconds(1.5f);
        //could set a speed off the start speed instead, then hardcode it so its not effected by whats set in editor
        paddleSpeed = 50;
        rb.constraints = RigidbodyConstraints.None;
        rb.constraints = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;       
    }

   
}

First guess is that it’s not reporting the device type so you get no touch inputs.

I have never used that. I harvest all touches and all keys all the time.

Time to start debugging! Here is how you can begin your exciting new debugging adventures:

You must find a way to get the information you need in order to reason about what the problem is.

Once you understand what the problem is, you may begin to reason about a solution to the problem.

What is often happening in these cases is one of the following:

  • the code you think is executing is not actually executing at all
  • the code is executing far EARLIER or LATER than you think
  • the code is executing far LESS OFTEN than you think
  • the code is executing far MORE OFTEN than you think
  • the code is executing on another GameObject than you think it is
  • you’re getting an error or warning and you haven’t noticed it in the console window

To help gain more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.

Doing this should help you answer these types of questions:

  • is this code even running? which parts are running? how often does it run? what order does it run in?
  • what are the values of the variables involved? Are they initialized? Are the values reasonable?
  • are you meeting ALL the requirements to receive callbacks such as triggers / colliders (review the documentation)

Knowing this information will help you reason about the behavior you are seeing.

You can also supply a second argument to Debug.Log() and when you click the message, it will highlight the object in scene, such as Debug.Log("Problem!",this);

If your problem would benefit from in-scene or in-game visualization, Debug.DrawRay() or Debug.DrawLine() can help you visualize things like rays (used in raycasting) or distances.

You can also call Debug.Break() to pause the Editor when certain interesting pieces of code run, and then study the scene manually, looking for all the parts, where they are, what scripts are on them, etc.

You can also call GameObject.CreatePrimitive() to emplace debug-marker-ish objects in the scene at runtime.

You could also just display various important quantities in UI Text elements to watch them change as you play the game.

If you are running a mobile device you can also view the console output. Google for how on your particular mobile target, such as this answer or iOS: How To - Capturing Device Logs on iOS or this answer for Android: How To - Capturing Device Logs on Android

If you are working in VR, it might be useful to make your on onscreen log output, or integrate one from the asset store, so you can see what is happening as you operate your software.

Another useful approach is to temporarily strip out everything besides what is necessary to prove your issue. This can simplify and isolate compounding effects of other items in your scene or prefab.

Here’s an example of putting in a laser-focused Debug.Log() and how that can save you a TON of time wallowing around speculating what might be going wrong:

When in doubt, print it out!™

Note: the print() function is an alias for Debug.Log() provided by the MonoBehaviour class.

I’ll try this out and look further into it thanks soooo much for the response, you’ve given me a lot to look into :). I’ve done some of these but the additional info might give me a clue and I’ll look into it