playMaker

Author Topic: Best way to check for item collection (Bool Array? Bool All True?)  (Read 3648 times)

whelly

  • Playmaker Newbie
  • *
  • Posts: 11
I've done a lot with Playmaker (and I love it), but I'm usually not sure I did it the best way. I wanted to get some ideas and see how you would do it.

In my game, there's a Steam achievement that unlocks when you examine a certain amount of objects. I've got achievements working fine, but I just don't know the best way of checking if the right amount of objects have been examined. I was thinking of creating around 20 global bool variables, and marking them as true when you examine the objects. Then there's a Bool All True FSM running every frame and checking if the correct amount of objects have been examined. I'm worried because every frame can be performance hog (I think), especially if it's having to check 20 or so global variables. Maybe I could do a Send Event action that only checks when you examine an item, but how does that work with Bool All True when there's only one transition?

Hopefully that all makes sense. Let me know what you guys think. Thanks!

DarkSoul

  • Playmaker Newbie
  • *
  • Posts: 37
Re: Best way to check for item collection (Bool Array? Bool All True?)
« Reply #1 on: August 14, 2015, 04:21:44 PM »
Hi,

My opinion is This kind of stuff is better done using global int variable
ExaminedItemsInt = 15
When Player examine something just +1 To that variable.
Then check if that intger is less or equal 20 everyframe ,
your game wont lag while checking one variable every frame.

I Hope This Helps.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Best way to check for item collection (Bool Array? Bool All True?)
« Reply #2 on: August 14, 2015, 04:29:21 PM »
Hi,
It is always better if you do not have to use every frame
You can use a Global transition (it will show on top of the state) it will always start again from there when it is called (even when a different state is active at that moment)

For the bools, maybe you could use a int variable and add 1 for each achieved achievement and use an int compare.
in that way if you add more achievement you can just adjust the int compare amount. and you need only 1 global
But that depends on your project.
if you are not planning to add more you can leave it like it is.

whelly

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Best way to check for item collection (Bool Array? Bool All True?)
« Reply #3 on: August 14, 2015, 05:24:15 PM »
This is great info, thanks. I had never heard of global transitions, but I'll definitely be using that, along with using Int variables. Here's another question on something I'm stuck on. The FSM on the examinable objects loop, so how would I do +1 int and keep it from looping in the FSM? For example, you pick up the object, it adds +1 to the global Int variable. You pick it up again, now it's 2. Basically I want it to add 1 only once, even though you can pick up the object again. Should I just add a separate FSM on each object?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Best way to check for item collection (Bool Array? Bool All True?)
« Reply #4 on: August 14, 2015, 06:55:31 PM »
Hi,
yeah i only found out global transitions a year after i used playmaker ;P

for your question,
it depends if they need to be saved the next time you play the game or not
and if you are using prefabs.

if not then you could use a local bool to check if it was picked up or not, before the "+1 int"

if yes, you might wanna use array maker