playMaker

Author Topic: [SOLVED] "Get Tag Count" with every frame  (Read 5336 times)

TommyA

  • Playmaker Newbie
  • *
  • Posts: 26
[SOLVED] "Get Tag Count" with every frame
« on: April 01, 2013, 12:24:02 AM »
Hi,
I'm testing the FSM with "Get Tag Count" action, but there is no "every frame" option. I need to check the specific tag count with "Get Tag Count" and "Int Changed" actions at the starting state of FSM.
So if tag count has been changed, it will fire to next event.
Could you advise me?

Tommy
« Last Edit: April 02, 2013, 05:35:41 AM by TommyA »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: "Get Tag Count" with every frame
« Reply #1 on: April 01, 2013, 05:31:25 AM »
Hi,

 I can create a custom action do let you do that, but really, If you are in control of the object you created that has this tag, then the object itself should fire the event, that will be a lot more efficient.

Could you explain the use case?

 bye,

 Jean

TommyA

  • Playmaker Newbie
  • *
  • Posts: 26
Re: "Get Tag Count" with every frame
« Reply #2 on: April 01, 2013, 08:11:42 AM »
Thank you for the answer.

In my case, I'm making UI layout and action.
I have 10 slots of character, but only need to select 5 characters to start game.
If I select only 4, the play button will be disabled. It will be enabled in case 5 selected.
When I click the slot to select, "selected mark" will be on the slot.
So I need to check "selected mark"(game object) count with tag every single frame.

I made this temporary like below.
Start -- State1: "Get Tag Count", "Next frame Event"
--State2: "Int Compare" (compare tag count with 5 to activate button or disable button)
--State3: Activate button
--State4: Disable button

In this case, It works but I think there's loop problem. (there's no loop waring in the event console, but in the playmaker graph view, it runs like loop)
I'm not a programer but designer. I'm sure there's another efficient way.
« Last Edit: April 01, 2013, 08:30:05 AM by TommyA »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: "Get Tag Count" with every frame
« Reply #3 on: April 02, 2013, 03:28:32 AM »
Hi,

 yes that starts to be very involving in terms of programming :) but that's doable.

 basically, instead of counting like this, you can do the following:

 maintain a global fsmInt "selected player count", that represent the number of selected players.

Each players when selected ( the ui component), increase this "selected player count" by 1, and when deselected decrease the counter by 1.

 straight away after you have selected or deselected a player ( still on the ui component), you check "selected player count" and disable or enable the play button like so.

 You can keep the logic of enabling disabling the play button on the play button itself, simply fire a "CHECK" global event from the player ui component when selected or deselected.

Does that make sense?

bye,

 Jean

TommyA

  • Playmaker Newbie
  • *
  • Posts: 26
Re: "Get Tag Count" with every frame
« Reply #4 on: April 02, 2013, 05:25:17 AM »
Hi Jean,
I made this as you said. (with global variable and global event)
It works well more clearly!  :D

Thank you for great support!

Tommy

RAWilco

  • Playmaker Newbie
  • *
  • Posts: 20
    • StinBeard
Re: [SOLVED] "Get Tag Count" with every frame
« Reply #5 on: April 07, 2014, 04:27:24 AM »
I realise that this topic is quite old, but the fact that the Get Tag Count action does not have an Every Frame option has been annoying me as well.

I wanted to set up an FSM to keep track of the number of NPCs I have roaming around in my level by using tags to count them. Naturally I wanted this to be live updating so that the variables keep track of when my NPCs "die" (despawn).

My solution to the lack of an Every Frame option was to have a single state FSM with the Get Tag Count action that loops back on itself using the FINISHED event. This does cause an infinite looping error however, so to get round that I added a 0.1 second Wait action that slowed the loop down.

This isn't exactly a neat and tidy solution though, so it would be nice to see an Every Frame option added to the Get Tag Count action in a future update.

purbanics

  • Junior Playmaker
  • **
  • Posts: 55
Re: [SOLVED] "Get Tag Count" with every frame
« Reply #6 on: April 07, 2014, 06:17:25 AM »
You could also try the Next Frame Event:
https://hutonggames.fogbugz.com/default.asp?W349

Br,
Peter

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: [SOLVED] "Get Tag Count" with every frame
« Reply #7 on: April 07, 2014, 06:53:34 AM »
Hi,

 It's preferable to act proactivly on these kind of counter.

 instead of keep counting objects everyframe ( which takes performances out), deal with your counter when your object is created and destroyed.

 so in your logic, increment that counter when you instantiate one of these object and decrement it when one of them is destroyed.

It's more work, but generally a MUCH better practice.

Bye,

 Jean