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;
}
}