playMaker

Author Topic: Updating Gui Text on collision [SOLVED]  (Read 1794 times)

sascham

  • Playmaker Newbie
  • *
  • Posts: 9
    • View Profile
Updating Gui Text on collision [SOLVED]
« on: November 13, 2011, 12:42:06 AM »
Hi,
I figure out how to set the text Value for an Gui Text.
I want to do an counter but the variable for the gui text seem to be local and
i can't update it during the some other objects collision. I have 2 global variables, and int and and string.
I set the int 1st  Int Add and convert it to the string and then want to update the gui text.

I use 1 gui text FSM and one game object FSM that based on collision updates the Gui Text.
I could do this via JS but wonder if it possible to do so also via playMaker.

Please advice

Thanks
« Last Edit: November 30, 2011, 08:37:41 PM by alexchouls »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13401
  • Official Playmaker Support
    • View Profile
Re: Updating Gui Text on collision
« Reply #1 on: November 13, 2011, 10:55:03 PM »
Hi,

 I think I understand what's the issue.

 Maintain a separate fsm that's responsible for counting and one responsible for displaying.

First:
 Can you increment an integer fine within your current system? do not output anything on screen, just se the var as "inspector" and watch the value, if it changes ok, then the next step is to have a second fsm that will every frame check of that number is different from its local reference, and if so then it means it needs updating visually. So in that fsm you maintain the actual current int that you really show on screen, that's the value you will compare with the real counter.

with this kind of setup you can then add some nice fancy effects, like if you have ten collision in a split of a seconds, you can increment by one every x tenth of a second the gui text until you reach the counter value. this will give a sense of value animation and will attract attention that indeed the value is changing.

 Does that make sense?

 Bye,

 Jean

sascham

  • Playmaker Newbie
  • *
  • Posts: 9
    • View Profile
Re: Updating Gui Text on collision
« Reply #2 on: November 14, 2011, 08:06:00 AM »
Hi Jean,

it makes sense, just some questions, i will try to build and example out of this and attach here later for people to use as well.
If I understood you correctly, I would for example attach one Integer Value to my main object, this value would increase based on collision, a 2nd FSM would check that value against his own value and if different adjust and update it on the screen ? sounds that about right?
All variables I guess need t be global "float" ?

Thanks
Sascha

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13401
  • Official Playmaker Support
    • View Profile
Re: Updating Gui Text on collision
« Reply #3 on: November 14, 2011, 10:17:58 PM »
Hi,

Yes, your rewording is correct :)

 No, it doesn't have to use global variables at all. You have actions to access int of a particular fsm ( "get fsm int" in category "state machine"). Depending on your needs, you can of course use global variables, if a lot of fsm are indeed accessing one of these value. In terms of performance, I am not sure if there is a gin when using global vars, I guess there is one, because the access is likely to be more direct then via a fsm reference, but I would not think it's noticeable, so I would go for what makes sense in terms of logic and needs of your game. I would suggest to start with local variables ( because it is better to keep things encapsulated as much as possible), and if that doesn't fit, then move onto global var.


 Bye,

 Jean