Player input, GUI, and Actions

Forums 💬 NodeCanvas 🗨️ General Discussion Player input, GUI, and Actions

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #13631
    vonwolfehaus
    Participant

      I’m a bit new to Unity and I’m still exploring NC and it’s really cool so far! I’m still learning how to effectively use it though. However, I’m not new to coding or game development, so it’s ok to use big words 😉

      I recently came across a problem where I need to handle input from the player in the game world, but that input should be blocked if they were just clicking on a GUI element. I had if (Input.GetButtonDown("Fire1")) { } in an Action, so it still runs even though the GUI element should have blocked it, but at least I got the event easily.

      I’m currently using Unity’s Event System (with Graphic/Physics Raycasters) so the GUI blocks input on GOs in the world. The problem is adding pointer events to Actions after they’ve been filtered by the casters. So I just want a “filtered” pointer up/down handler in an Action (not an NC Condition since that got messy _really_ fast). What’s the best way to handle this situation?

      Thanks for any suggestions!

      #13634
      Gavalakis
      Keymaster

        Hello and sorry for the late reply due to summer vacation.
        Thank you! I am glad you like NodeCanvas thus far 🙂

        Please excuse me in advance if I misunderstood the question, but you can if required get a callback for the pointer-based unity events in actions. One way to do that, is by using the [EventReceiver] attribute, which accepts a params array of messages/events (in string names) to subscribe the action to, where the gameobject that would be used for those callbacks, will be the “agent”. Here is an example of how this can be done:

        Is this indeed what you’ve asked, or did I misunderstood the question.
        Please let me know.

        Thank you!

        #13633
        vonwolfehaus
        Participant

          Thank you! I didn’t think to use an attribute. This is what I was hoping for. Thanks again for your help.

          #13632
          Gavalakis
          Keymaster

            You are very welcome!
            If you have any more questions please do let me know 🙂

          Viewing 4 posts - 1 through 4 (of 4 total)
          • You must be logged in to reply to this topic.