Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Loque on April 29, 2017, 03:25:11 PM

Title: Wait to have a value before doing anything ?
Post by: Loque on April 29, 2017, 03:25:11 PM
Hi guys,

I have an fsm with a string compare in it.
The problem is that when I launch the game the value stored in my variable is blank (because it takes a bit of time to get a value).
So it compares to a blank value so it always fails to know if the value is equal or not.

I know I can add a "wait" at the beginning of the action, I tried it and it works. But the problem with that is that it will fail if I add more things in the future and instead of taking 1 second to get the value, it takes 2 seconds etc.

So I'd like to know if there is an action to wait for the value to be filled, then go to the next action.

Thanks
Title: Re: Wait to have a value before doing anything ?
Post by: Loque on April 29, 2017, 05:42:16 PM
Ok, I found a way of doing it.
With the "send event" action and using a global event. Is it the best way of doing it or is there a liter / better / easier way (even if it's pretty easy to do :D) ??
Title: Re: Wait to have a value before doing anything ?
Post by: LordHorusNL on April 30, 2017, 08:00:25 AM
In a situation like this i almost always use a global event to trigger a state and i think it's your best option yes, i am however also curious to know if there is a huge downside to using a lot of global events for stuff like this.
Title: Re: Wait to have a value before doing anything ?
Post by: Breadman on May 02, 2017, 04:02:01 PM
There is a "string changed" action which will fire an event only when a specified string changes (but only while the state with the action is the active state). Depending on how your FSM is set up, you could use this action in your "wait" state.

Rather than having your "string compare" state be the first state, make a new start state with "string changed", and then have the FSM switch to your "compare string" state immediately after the string changes. This should cause the string to be compared only when the FSM detects it has changed.
Title: Re: Wait to have a value before doing anything ?
Post by: Loque on May 04, 2017, 02:06:19 AM
Oh Thanks !!
I used a really small delay in the end but may definitely use that "XXX changed" action on some of my FSM.