playMaker

Author Topic: UI text label that will be controlled by many GameObjects?  (Read 993 times)

Lombardi

  • Playmaker Newbie
  • *
  • Posts: 1
UI text label that will be controlled by many GameObjects?
« on: June 04, 2020, 06:27:37 PM »
Hi All!! I am new to the forum!! thanks for taking the time to help me on my Playmaker journey!

I have 2 wooden post signs...

When I click on PostSign1, I want to display "Ivory Inn" on a UI text label then the text fades away.

When I click on PostSign2, I want to display "Tavern" on the same UI text label then the text fades away.

How would you proceed to do that? Use a global variable to talk to the UI text label from multiple objects?

Where would you place the fade actions, on the main label or on each signs?

What I want exactly is that when you click on the first sign repeteadly, the fsm start over and over again until you leave it go and the text fade on the label.

So that if I click any signs at any moment the text will display and fade away / And that if I would click any signs after having already clicking a sign the process would start right over.

So that if I click any signs, the action of writing text to the main label start over again and it doesnt bug when the text is fading away

Right now when I click sign1, "Ivory Inn appears" and when its fading away and i click sign2 at that very moment, it says "Tavern" already fading out... well it doest work.

I hope you understand!

Here is a screenshot of what I have right now!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: UI text label that will be controlled by many GameObjects?
« Reply #1 on: June 05, 2020, 02:28:33 AM »
Hi.
I would set the fader and set text in a seprate fsm on a empty game object called Ui Handler.
The Ui handler could be set as a global if you need to access it with prefabs or cross scenes.

So on that fsm :

Start state : just a empty state that does nothing (i usually call it 'Idle')

State 2 :
have a Global Transition (cal it "Show Text" for example)
Then :
Set Text Action
then fader action(s)
and connected direction to the text object.
Then possibly do a set text with no text in it to clear the text but that might not be necessary.

Then on post sings when selected :
State 1 :
Set Fsm Text
Then Send Event (by Name) and send "Show Text" on the Ui handler object.

If you can connect to the 'Ui handler Directly and you wont use spawned prefabs to communicate with it or cross scene (meaning multiple scenes active and something from another scene needs to access the Ui handler)

Then don't use a global variable.
you should always try to minimize using global variables.

Here's a video about Global events / transitions :