1

I am creating a turn based game where I am allowing users to Navigate throughout the scene using left clicks. At the Bottom of the screen, I have a skill bar that holds abilities, however, when I click on one of those abilities, my scene thinks I am trying to navigate using my player. How can I get my GUI to ignore raycasts, and prevent my character from moving if my mouse is overtop of it? My Scene is set up like this:

Example of my Scene Setup

Some of the answers I have found online say to use a panel and set its' Raycast Target checkbox to false, which should stop raycasting through that panel, if I understand that correctly. However, that does not solve my problem.

This is my scene view:

The red circle is the issue

I want to be able to click within that red circle to command an attack, however, my navMesh thinks it is time to navigate. Any advice is greatly appreciated.

Rinktacular
  • 1,116
  • 3
  • 19
  • 45

1 Answers1

1

Taking my answer from over at Game Dev on a similar question:

You have a few options:

  • When the UI is up, set some global variable (eg. gamePaused) that when true, your game logic doesn't execute. This includes shooting.
  • Ask the event system: EventSystem.current.IsPointerOverGameObject()
  • Check if your mouse is in a region of the screen (eg. over/not over the UI) and if over the UI, don't fire.

The first one doesn't apply to you, the second is probably the best, but the third works well in some cases (when the game area or UI area is bounded by a single rectangle).

  • Yeah I saw that EventSystem execution in another question, but the approved answer said it was outdated, but I'll give it a go anyway. Thank you! – Rinktacular Jan 24 '18 at 18:34
  • 1
    @Rinktacular The package name of the Event System has changed, that's probably what happened. Even when I made that answer I found `EventSystemManager.currentSystem.IsPointerOverEventSystemObj‌​ect()` first, which is an older naming. – Draco18s no longer trusts SE Jan 24 '18 at 18:35
  • Cool, well that was a solution, Thank you for your help – Rinktacular Jan 24 '18 at 18:37