playMaker

Author Topic: Little issue with UI buttons and status bars of the player. [SOLVED]  (Read 638 times)

ChuuMan

  • Playmaker Newbie
  • *
  • Posts: 2
Hi,

I'm trying to make a basic interface for a Virtual Pet little game and beginning with some basic buttons for triggering increase and decrease of the Hunger/Hygiene/Sleep/Joy.
So basically, you click on the Food button, Hunger bar go up and Hygiene bar go down by 1.


I have 2 problems with this situation, maybe with a relation between them, i honestly don't know.

First, i can't see the way to make the button clicking once and not entering the selected state, there is something i don't get but i don't know what.

And second, when i click on, for example, Food button (Hunger +1/Hygiene -1) and after that, click on the Hygiene button (Hunger -1/Hygiene+1), the first click on Hygiene still trigger the Food button, and once again, i have no clue about why.
Maybe UI button isn't the right solution, maybe i can't see the simple thing to solve the problem or it's something else.

Some pictures with the value of the bar in the inspector on the right after the click :

Food Button clicked :


Wash Button clicked first time :


Wash Button clicked a second time


I tried Youtube tutorials, searched in this forum for old problems but wasn't able to find a solution for my problem, so, if anyone has an idea, i'm open to try, thank you !
« Last Edit: May 16, 2023, 09:27:08 AM by ChuuMan »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Little issue with UI buttons and status bars of the player.
« Reply #1 on: January 09, 2023, 03:34:51 AM »
Hi. UI click will probably trigger on Any ui you click.

Use Ui Button On Click Event, or on the button component in the On Click part, click the +
Then Drag and drop the Playmakerfsm Component (not the game object) that you want to communicate with.
then click on the "No Fuction" and select PlayMakerFSM/Send Event and put the event name that you want to send.

ChuuMan

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Little issue with UI buttons and status bars of the player.
« Reply #2 on: May 16, 2023, 07:47:53 AM »
Hi,

Sorry for the delay, life stuff happened and wasn't even able to touch Unity since January.
Well i'm back in business for days and still can't pass the problem, each time i click on 1 of the 4 buttons after another, the first click still trigger the last button i clicked once before doing his own job at the second click.
I tried dozens and more of different combinations with transitions or not, global, multiple and in between state, OnClick Event etc. They all worked but all with the same exact problem.
I begin to run out of ideas, maybe i need to erase everything and do it again in a brand new scene. I just don't know at this stage tbh.
So, if anyone has an idea, a method who work with multiple button in a single canvas, i'm open for more suggestions.

Ty in advance and have a nice day everyone !

EDIT :
I did it !
Needed to complain to finally have an illumination.
Until now, i had in each button a Start state and a second state which contained all my increase and decrease operation. and this second state was the event called by the OnClick Button.
The way to finally break the curse was to add a FINISHED transition to the second state, leading to a third state which contain a Next Frame Event action with the Send Event calling FINISHED and i added a FINISHED transition connected to the first state being my START.


Can't believe i struggle hard with a simple/basic element like that, the gamedev journey will be long, hard and full of low and high, have a nice day everyone and stay strong !
« Last Edit: May 16, 2023, 09:26:21 AM by ChuuMan »