playMaker

Author Topic: Puzzle, 100cubes + FSMs = too much?  (Read 2856 times)

bkups2003

  • Playmaker Newbie
  • *
  • Posts: 49
Puzzle, 100cubes + FSMs = too much?
« on: September 03, 2013, 11:51:30 AM »
Hello, I'm planning a puzzle game with 100 cubes. They need to be selected and whatever to get points. In the examples i have seen from arraymaker, they use an FSM on each cube, in one example using MOUSE DOWN, to select cubes. But there were only 5 cubes, so 5 FSMs. Now that i need to make a full puzzle game with 100 cubes, having a MINIMUM of 100 FSMs in a scene all at one time, would the performance be affected?

I read that the less FSMs, the better. But is there a way to reduce the FSMs? All cubes are exactly the same with exactly the same FSMs.

Thanks.

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4002
  • Official Playmaker Support
    • LinkedIn
Re: Puzzle, 100cubes + FSMs = too much?
« Reply #1 on: September 03, 2013, 12:47:40 PM »
Performance wise it should be fine. Since that is the setup that you have working now, I would stress test that *on your target device* before changing it.

Or you could switch to a central manager. One FSM that detects the type of block clicked and does the appropriate thing.

Depending on the design of your game this might make more sense anyway, since you'd implement the game rules in one place instead of on every block...

bkups2003

  • Playmaker Newbie
  • *
  • Posts: 49
Re: Puzzle, 100cubes + FSMs = too much?
« Reply #2 on: September 04, 2013, 07:14:24 PM »
thanks for the reply. my target is lower range single core android phones starting at about a 1ghz processor. i would like to centralize it but i cant find a way to have a mouse enter like event when entering a colider.

is there a way to have a cube grow when entered ? ideally i need to be able to move across many cubes and have them grow .

i feel mouse pick is close, but i cant figure out how to make it only go to the next state  only when a  gameobjec is picked, or better yet,  when a gameobject that is not the same as the last is picked. any way i think of ends in a 1000 loop limit reached, or stays in pick set to update each frame and never going to the  next frame.

any advice?

please excuse the terrible english. im using a mobile with a terrible keyboard app.

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4002
  • Official Playmaker Support
    • LinkedIn
Re: Puzzle, 100cubes + FSMs = too much?
« Reply #3 on: September 04, 2013, 08:48:21 PM »
Only do the Mouse Pick when the user presses a mouse button. So there's an Idle state with Get Mouse Button Down. When the user presses the mouse button go to a Pick state that runs Mouse Pick and decides what to do based on the object picked. Then returns to Idle.

To grow the cubes you could use an animation. So the central manager can just use Play Animation on the GameObject picked.

I've attached a screenshot to show the general pattern. I used a global Reset transition back to Idle to keep the graph tidy. So Blue Block Picked etc. just sends the Reset event to go back to Idle. 

bkups2003

  • Playmaker Newbie
  • *
  • Posts: 49
Re: Puzzle, 100cubes + FSMs = too much?
« Reply #4 on: September 04, 2013, 11:45:15 PM »
oh that far ive got pretty spot on. sorry i didnt explain too clearly what im doing. the first click is jo problem. i get that object and add to database. then i want to be able to keep holding thr mouse down and drag over other cubes to select them too.  so thr first cubes fine with the get mouse down. but i cant figure out a way to keep it down and drag it over other cubes to select them too. i can just .of having each cube have its own fsm that has a mouse enter global fsm that checks if thr mouse is down in the next state. is there a way to get this type of functionality in just 1 fsm?

thanks again for taking the time to answer all my questions.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Puzzle, 100cubes + FSMs = too much?
« Reply #5 on: September 05, 2013, 07:21:33 AM »
Are you looking for a rectangle selection box?

http://hutonggames.com/playmakerforum/index.php?topic=2598.msg15738
http://hutonggames.com/playmakerforum/index.php?topic=3448.msg15847

If you're just trying to pick objects by moving the mouse around you should close to what you need in that image Alex posted, when finished with blue/red selected store the object(s) [likely with arraymaker] and return to the Pick state.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D