playMaker

Author Topic: [SOLVED] Problems with sending events  (Read 2424 times)

kathode

  • Playmaker Newbie
  • *
  • Posts: 6
[SOLVED] Problems with sending events
« on: December 29, 2013, 01:49:26 AM »
Hi,
I'm totally new to Playmaker so apologies in advance if I've done something dumb!

I am working on a click-to-move system with multiple characters.  Very similar to FTL if you've played it - click on a character, that character becomes the active character, and responds to your commands.  Any other character becomes "deactivated" and doesn't respond any longer.

I'm attaching a shot of how I have things set up.  The graph in the pic is duplicated for both characters.

When I make a character active, I broadcast a "deactivate character" global event.  However, this event seems to be getting ignored.  If I click on the second character, the first character doesn't deactivate, and they both start moving towards my mouse clicks.  I think I have something set up wrong.  Could anyone let me know?

Thanks!
« Last Edit: December 29, 2013, 02:13:09 PM by kathode »

colpolstudios

  • Sr. Member
  • ****
  • Posts: 370
Re: Problems with sending events
« Reply #1 on: December 29, 2013, 04:30:53 AM »
Hi i am also quite new but your global event is in the original state.

When you click to make the new character active you will always send the "deactivate character" global event.

A better way to do this would Name your FSM "activate player" for example.

Then copy all of the states into a new FSM For your other characters give this a special name.

Then instead use enable FSM to switch off the FSM`S you wish.


bizilux

  • Full Member
  • ***
  • Posts: 171
Re: Problems with sending events
« Reply #2 on: December 29, 2013, 09:23:36 AM »
what colpolstudios said will probably fix it yes... keep things in their own FSM's. you can Add new FSM to selected gameobject


PS: you sure did make a mess in there with that FSM :) arrows gone crazy haha

check my FSM how organized it is... if i would drag arrow from everything back to start... it would be a mess, not organized at all...  instead, what i did was add global event called "restart" to first state... so first state has Start and restart global events...

so when i would normally drag arrow back to start... i just use send event, "restart event"

doesnt change any functionality, just makes everything look a lot more nicer... which is what you want really in the long run :)

kathode

  • Playmaker Newbie
  • *
  • Posts: 6
Re: Problems with sending events
« Reply #3 on: December 29, 2013, 02:12:54 PM »
Thanks for the tips!  I didn't know about the restart.  I thought I had to make "loops" which is the cause of the arrow mess.  I will work on that and get things cleaned up.

I figured out the specific problem in this instance - The fact that the "Set_Active_Player" event was at the top meant it was getting fired off first, and the graph was reacting to that and moving on without sending the event below it.  I was dumb and was thinking that all actions in a single step would get fired off regardless.  Finally figured it out after working out some of the debugging tools.

The best thing to do here would be to have some kind of active manager that controlled this logic.  However, I don't know how many characters the player might have in this game, so I would have to use an array and iterate through each member.  Or just had the thought, I could just store the last active character in a variable.  Anyway, I don't want to overcomplicate things for the prototype - as you can see, even simple problems are throwing me off at this stage!

Thanks again for the help.

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: [SOLVED] Problems with sending events
« Reply #4 on: December 29, 2013, 05:20:47 PM »
theres a lot of way you can do what you want...

you can either make a lot of booleans, few booleans per character, that would be called something like "active" and "highlight",  and whatever else you want to do with character... and then turn them true/false accordingly..

or you can have what you said. have 1 string variable  "selected character" . then you have some emptygameobject called "character management" or whatever name you want it... and on there have FSM, that in the first state, it has action called "string switch"  and in there you compare string variable, with all possibilities of the characters...

lets say they would be called: soldier, mechanic, pilot. so you would compare it to this 3 things, and then fire events based on that, and do stuff there... if you had soldier event fired, then you would for example have next state where you would disable highlight on mechanic and pilot... and so on

the same example i've shown you actually uses this too... it is part of AI traffic, for bus simulation. and checks what is the name of the path that just ended, so that it can put AI car onto the next path that follows it...

i just hope you were asking about that :)