I want to make that where I touch with my finger on the phone screen the player will move to that position.
using UnityEngine;
using UnityEngine.UI;
public class MobileControls : MonoBehaviour
{
private void Update()
{
if (Input.touchCount > 0)
{
Touch touch = Input.GetTouch(0);
Vector3 touchPosition = Camera.main.ScreenToWorldPoint(touch.position);
touchPosition.z = 0f;
transform.position = touchPosition;
}
}
}
no matter if the camera is setting to perspective or to orthographic the player is just moving somewhere away far away from the camera.
the script is attached to the player.
on my phone android I’m using unity remote application and the Developer options enabled on my phone already.