playMaker

Author Topic: FSM question about update with IF statement  (Read 2358 times)

johanesnw

  • Playmaker Newbie
  • *
  • Posts: 26
FSM question about update with IF statement
« on: March 20, 2014, 10:32:32 AM »

so here I'm trying to make something like this (not very familiar with code  :P)
Code: [Select]
void Update()
{
     if (this.maxAtk > GlobalMaxAtk)
             GlobalMaxAtk = this.maxAtk;
}

there are 3 objects that will have this same FSM, so when the conditions met, it will send event to the manager object to update the GlobalMaxAtk.

the FSM above will result error as it has 1000+ Loops. and if I remove the transition event it will locked in that state and moves nowhere

TIGGYsmalls

  • Junior Playmaker
  • **
  • Posts: 80
Re: FSM question about update with IF statement
« Reply #1 on: March 20, 2014, 10:56:35 AM »
What are you doing to check? Mouse press, button press?

Perhaps you should Send a Global Event when whatever happens, happens.

johanesnw

  • Playmaker Newbie
  • *
  • Posts: 26
Re: FSM question about update with IF statement
« Reply #2 on: March 20, 2014, 11:13:07 AM »
It's checking for x position of 3 object. That maxAtk is not actually a damage calculation, but max range to atk.
So to update each x position i need to check every frame whether the current object x position has highest value.
If its greater than max, it will update the max value.

Doesn't relate to btn press or such,

TIGGYsmalls

  • Junior Playmaker
  • **
  • Posts: 80
Re: FSM question about update with IF statement
« Reply #3 on: March 20, 2014, 11:26:01 AM »
Ok, on each object I think you'll need:

Get Position and click every frame.
Float Compare and click every frame.

When X is greater than whatever, send the event.

johanesnw

  • Playmaker Newbie
  • *
  • Posts: 26
Re: FSM question about update with IF statement
« Reply #4 on: March 20, 2014, 03:58:39 PM »
Nah case closed.
I end up code using coroutines. It's much more simpler.