playMaker

Author Topic: Activating a scene when multiple triggers are activated.  (Read 5219 times)

motiondisabled

  • Playmaker Newbie
  • *
  • Posts: 5
Activating a scene when multiple triggers are activated.
« on: January 17, 2012, 07:05:35 AM »
Hi I was wondering if anyone can give me an idea on how to make a state system for my game.

I have a puzzle game were you slide each piece into the right place and when all are in the right position they make a picture and then load a scene but if one of the pieces are not in the right place then it wont work. I have tried many ways but i cant work out how to this.

I have:

8 colliders/triggers
8 puzzle pieces

Thanks for any help.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15594
  • Official Playmaker Support
Re: Activating a scene when multiple triggers are activated.
« Reply #1 on: January 17, 2012, 08:47:19 AM »
Hi,

 You need to implement some kind of logical representation of your game progress.

 you need to be able to know if a piece of the puzzle is on the right slot or not. This is your first step.
 Then, you have several options to check if a puzzle is complete.

 either, you maintain an simple integer as a global int ( you know what I mean by that yes?). And each piece when moved, check for its state and increment by one or decrement by one  this integer, so if you have 10 piece. If the int is equal to 10, then it means all pieces are in place, you win. This technic would imply that when initializing the game, you don't forget to have each piece checking for its state, cause some might be on the right spot already.

 One other way would be:
1: set a boolean value "is puzzle complete" to true
2: to send a global event "CHECK" for example, and each piece would receive this event. If one piece is not in place, then it throws a global event "FAIL", the fail event would set "is puzzle complete" to false.
3: you then simply check for "is puzzle complete" after you sent that "CHECK" event and you know if the user won or not.

 Hopefully, you understand what I mean, if some concepts are missing, let me know, I'll explain more in details.

Bye,

 Jean

Red

  • Hero Member
  • *****
  • Posts: 563
Re: Activating a scene when multiple triggers are activated.
« Reply #2 on: January 17, 2012, 01:01:00 PM »
could also use the "bool all true" action as a test... feed it all the bool variables (such as "tile 1 is in the correct place") and when they're all reported to be true, fire off the action you're looking to do.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15594
  • Official Playmaker Support
Re: Activating a scene when multiple triggers are activated.
« Reply #3 on: January 18, 2012, 12:50:44 AM »
hi,

 That's one solution, tho I prefer implementing solutions that can scale. if you hard code the number of puzzle pieces ( which could be fine for your case), you then have problem when you want to make the app evolve, because pieces numbers, name and references would be hardcoded in many different places.

tho, this might be the quickest approach actually :)

Bye,

 Jean