playMaker

Author Topic: Not sure I understand...  (Read 3012 times)

storm33229

  • Playmaker Newbie
  • *
  • Posts: 3
Not sure I understand...
« on: October 06, 2012, 01:32:59 PM »
I am trying to create a very simple enemy-chase AI. I've wasted 2 hours in PlayMaker attempting to get this right, when this can be coded in a matter of minutes. Needless to say, I think its about time I asked for help...

I'm pretty convinced I'm not thinking about things correctly...so here's an image of what I am doing:



The method being called in the SendMessage is empty, so its not hanging there. However Unity3D locks up entirely when trying to run this...

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Not sure I understand...
« Reply #1 on: October 06, 2012, 01:39:31 PM »
infinite loop .
In short,add a wait action somewhere, since FSM states can be called multiple times per frame (which is just amazing), and without adding a wait action it'll use all resources to get the job done... just to immediatly start all over again :D
Best,
Sven

storm33229

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Not sure I understand...
« Reply #2 on: October 06, 2012, 01:43:04 PM »
I would have to specify a time though. I'm really looking to just go to end of frame.

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Not sure I understand...
« Reply #3 on: October 06, 2012, 01:45:54 PM »
then use 0, the wait action is obliged to wait until the end of the frame. Or use .05 like me, to save some overhead (I mean, whoever is gonna realize the difference between .02 and .05 except for the performance :D)
Best,
Sven

storm33229

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Not sure I understand...
« Reply #4 on: October 06, 2012, 01:51:42 PM »
Alright, sounds good. Thanks :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Not sure I understand...
« Reply #5 on: October 08, 2012, 01:39:32 AM »
Hi,

 instead, I would have two message, "start chasing" and "stop chasing", that woul dbe triggered only when the ennemy becomes too far, or too close, but not every frame. this is not really a good process.

 in script, you do that fine in the Update, but in playMaker, you have to really think in terms of distinct actions on that kind of matter. So create a threshold value, say 4 5 units around the distance you want the ennemy to trigger, so fire "start chasing" when the enemy is distance+ 4 and fire "stop chasing" when the ennemy is distance -4. something like that.

bye,

 Jean