Well i was looking for some script to attach to my player so when i click over a tile on the gris he automatically walks to.
I got this so far
using UnityEngine;
public class TestTouch : MonoBehaviour
{
private InputManager inputManager;
private Camera cameraMain;
// Start is called before the first frame update
private void Awake()
{
inputManager = InputManager.Instance;
cameraMain = Camera.main;
}
private void OnEnable()
{
inputManager.OnStartTouch += Move;
}
private void OnDisable()
{
inputManager.OnEndTouch -= Move;
}
public void Move(Vector2 screenPosition, float time)
{
Vector3 screenCoordinates = new Vector3(screenPosition.x, screenPosition.y, cameraMain.nearClipPlane);
Vector3 worldCoordinates = cameraMain.ScreenToWorldPoint(screenCoordinates);
worldCoordinates.z = 0;
transform.position = worldCoordinates;
}
}
But with this code my player only move to the position where i touch like if teletransport.
By the way im new using Unity and learning to program.
Im looking for when i touch it moves smooth until he reach that point touched.
Any help?