playMaker

Author Topic: Pacman moves help  (Read 2315 times)

bufbot

  • Playmaker Newbie
  • *
  • Posts: 2
Pacman moves help
« on: January 17, 2014, 10:23:11 AM »
Hello people,

I'm starting a "pacman style" game, starting with the movements I have for now on mobile movement depending on swipe by using character controller, this part is working fine.

My next move is to do something like this :

- if there is a wall down when you swipe down it continues to go on the direction and it will turn down as fast as there is a possibility to do so (basically it remembers the last swipe to apply it whenever it's possible)

I tried few things already with detecting collisions but I couldn't really manage to do anything proper.

I'm just starting with playmaker but I hope that I will be able to make great things !

Thank you

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Re: Pacman moves help
« Reply #1 on: January 17, 2014, 11:07:02 AM »
Each swipe should be saved as a Bool variable. SwipedUp? True/False, SwipedLeft True/False etc etc once a new input is performed you then need to turn the other 3 to false. Probably best to set them up as Global variables so it can be referrenced from other state machines.


Then you'll always be able to check what the last input from the player was. On collision If SwipedUp = True - move up etc.

bufbot

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Pacman moves help
« Reply #2 on: January 17, 2014, 11:53:46 AM »
Thanks for your reply !

I will test this right now as it looks like a good idea !

Just another question coming from your solution, how should I make it move by itself when it'll be possible (bool set up to true but still moving in another direction ) ? by checking collision every frame or something like this ?

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Re: Pacman moves help
« Reply #3 on: January 21, 2014, 09:27:12 AM »
It's probably not the best way - but it should work. Maybe your pacman object can detect if there's a wall up/down/left/right and when ever this changes (no longer a collision up) it looks at the SwipedUp Bool and moves up.

It's just about setting up some logic rules and checking them every time the situation changes.

If you want to go that way, make a Pacman image, add a circle collision to it. Then create four more small collision objects, one to the left of Pacman, one above etc etc. Those four object should be positioned so they can detect changes in the walls around Pacman and feed this information back to a Playmaker State Machine that is keeping track and letting the player move when appropriate.

It's messy but it'll work if you keep the logic simple :D