playMaker

Author Topic: Click anywhere except on a button to exit state  (Read 1076 times)

PatternTree

  • Playmaker Newbie
  • *
  • Posts: 5
Click anywhere except on a button to exit state
« on: April 10, 2022, 08:46:05 AM »
Hey all! New to Playmaker but am LOVING it so far!

This might be a noob question but I am making a simple mobile game where you can allocate population to various tasks like "hunt", "research", etc based on how many pop points you have.

So far, I've set it up so that when you click on the Population icon, it will enter a state called "Allocating population". It will then send an event to the possible buttons you can click to allocate population there.

However, I want to make it so that when you click anywhere on the UI that isn't one of those buttons, it will exit the "Allocating population" state. But when you do click one of those buttons to allocate a pop there, it won't exit that state so that you can click multiple times and allocate several pop to the same thing until you click somewhere else to exit that state. But I'm not entirely sure how to best achieve this...


The best idea I've come up with so far is:
On the pop icon, set it so that on a UI CLICK, you enter Allocating pop state. This will send a global event to another FSM that's on an empty game object in the hierarchy. It will then enter a state called "is allocating". On there, there's a transition on UI CLICK that goes to a state that uses UI Get Last Pointer Data Info. It can then somehow check if the item clicked was one of the things you can allocate pop to. If it wasn't then it will exit the is allocating-state.

This seems a bit complex, is there an easier way of doing this?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Click anywhere except on a button to exit state
« Reply #1 on: April 10, 2022, 10:48:07 AM »
Hi.
Maybe you can use 'Ui Get Selected Game Object'
on changed event compare the selected object.

PatternTree

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Click anywhere except on a button to exit state
« Reply #2 on: April 10, 2022, 12:55:59 PM »
I'm afraid I don't quite understand how to make a "changed event" turn into "do this if it is a button" or whatever.. :/ It's still very interesting to try to figure out though! I'm still new but of course I am looking forward to making actual progress too.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Click anywhere except on a button to exit state
« Reply #3 on: April 10, 2022, 11:25:14 PM »
Hi.
The action will send a changed event if the selected object has changed.
then use some Game Object Compare actions to check if its one of those buttons to allocate a pop