Touch input c# Testing on Unity Remote 5

Hi there,

I’ve been trying to test car movement using Unity Remote 5 on my Samsung Galaxy M31 phone, but whenever I touch the screen of my phone, the car is not steering. The game runs np but it’s not steering whenever touching screen. Can you help me to know what the issue is about? The C# script or something about the app UR5?

my code is as follows atm:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.InputSystem;

public class Car : MonoBehaviour
{
   [SerializeField] private float speed = 10f;
   [SerializeField] private float speedGainPerSecond = 0.2f;
   [SerializeField] private float turnSpeed = 200f;

   private int steerValue;
   private Camera mainCamera;

    void Start()
    {
        mainCamera = Camera.main;
    }

    void Update()
    {
        speed += speedGainPerSecond * Time.deltaTime;
        transform.Rotate(0f, steerValue * turnSpeed * Time.deltaTime, 0f);
        transform.Translate(Vector3.forward * speed * Time.deltaTime);
        if(Touchscreen.current.primaryTouch.press.isPressed)
        {
            Vector2 touchPosition = Touchscreen.current.primaryTouch.position.ReadValue();
            Debug.Log(touchPosition);
            Vector3 worldPosition = mainCamera.ScreenToWorldPoint(touchPosition);
            Debug.Log(worldPosition);
        }
    }

    private void OnTriggerEnter(Collider other)
    {
     if (other.CompareTag("Obstacles"))
     {
        SceneManager.LoadScene(0);    
     }
    }

    public void Steer(int value)
    {
        steerValue = value;
    }
}

Unfortunately, Unity Remote 5 doesn’t work with the new input system.
https://forum.unity.com/threads/new-input-system-and-unity-remote-5.735968/#post-6200318

If I build the game and transfer the game to my phone via usb and test it, will the touch work that way?

Yes, it will work just fine. This is what I do as well. The trouble with the Unity Remote is that it hasn’t been significantly updated in a very long time.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms