I have a click to move option I learned from this guide:
The tutorial is excellent, but I do not know how to combine a test of which layer the past is clicked on, because I do not want for example, that when the mouse is clicked on the UI the character will not move foreign?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems; // Add this line
public class ClickToMove : MonoBehaviour
{
...
void Update()
{
if (Input.GetMouseButton(0))
{
// Check if mouse button was clicked over a UI element
if (EventSystem.current.IsPointerOverGameObject())
{
Debug.Log("Clicked on the UI");
return;
}
SetTargetPosition();
}
if (isMoving)
{
Move();
}
}
...
}
Thanks a lot for the help, but I want to check by layer and not by GameObject there is a way?