I'm currently facing this problem: If I click on a Button on my Canvas, the currently selected Unit moves towards the location under the Button.
Is is there any option to solve this? I'm using the A* Project for this.
Sadly, I can not provide a lot of things I've done so far as I absolutely have no clue how to solve this problem.
If I disable the Button Option "Raycast Target" it still moves to this position but holds a bit earlier.
Also, adding this as check didn't work:
if (!EventSystem.current.IsPointerOverGameObject() )
I also checked if the Raycast hits the layer of the GUI
My Movement code so far:
public override void MouseClick(GameObject hitObject, Vector3 hitPoint, Player controller)
{
base.MouseClick(hitObject, hitPoint, controller);
if (hasAuthority && player && player.human && currentlySelected)
{
if (hitObject.name == "Ground" && hitObject.name != "UI" && hitPoint != ResourceManager.InvalidPosition)
{
float x = hitPoint.x;
float y = hitPoint.y + player.SelectedObject.transform.position.y;
float z = hitPoint.z;
destination = new Vector3(x, y, z);
//Debug.Log("Start_Move");
StartMove(destination);
}
}
}
!EventSystem.current.IsPointerOverGameObject()
should work just fine with it. Check out this video if it still doesn't work UI Block \$\endgroup\$