playMaker

Author Topic: How would I make a Pac Man like movement with Playmaker? [SOLVED]  (Read 5297 times)

lordnovas

  • Playmaker Newbie
  • *
  • Posts: 4
I was playing with the getAxis sample but I had no clue as to how I would go about setting up movement similar to pacman where the player continues to move in the direction set by the players last input.

Would I need to reset the translate to equal the getAxis input and if so how do I do that :)

Any help is greatly appreciated.

Thanks.  
« Last Edit: April 06, 2012, 07:05:03 PM by Alex Chouls »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How would I make a Pac Man like movement with Playmaker?
« Reply #1 on: April 05, 2012, 12:42:56 AM »
Hi,

 It would be quit simple actually.

 have one fsm responsible to check the user input, when the user press up, fire a global event "GO UP", when the user press left, fire a"GO LEFT", etc

then, have another fsm, with each of these global events going to their respective state. then on each of these state, you translate by the desire amount in the right direction.

 Because of the nature of fsm, as global events are fired, your fsm will switch from one state to the other, and you'll get your behavior that as long as the user hasn't pressed another input, it will carry on moving.

then at start, you simply for one of these global event to start moving.

 Hope that make sense?

 Bye,

 Jean

lordnovas

  • Playmaker Newbie
  • *
  • Posts: 4
Re: How would I make a Pac Man like movement with Playmaker?
« Reply #2 on: April 05, 2012, 08:13:02 PM »
Ahhh, that makes sense. So rather than hooking up a character controller, simple move etc. I'm just going to move the character like an object, and when the user presses an input that I'm checking for I will move the character via translate in the corresponding direction.

Thanks a bunch, I sketched out and it appears logical. I'm gonna give it a whirl right now

lordnovas

  • Playmaker Newbie
  • *
  • Posts: 4
Re: How would I make a Pac Man like movement with Playmaker?
« Reply #3 on: April 05, 2012, 10:56:58 PM »
Question:

I've tried setting up a button checker but failed; would you mine showing me how to setup a switch that would check for 4 buttons being pressed.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How would I make a Pac Man like movement with Playmaker?
« Reply #4 on: April 06, 2012, 02:00:27 AM »
Hi,

 Here we go, attached a unitypackage with a packman you can control with the arrow keys.

 The next step would be to define how you intend to work out the pacman behavior as it hit walls, and for this several solution are possible, either you switch to full physics and instead of translating, you apply force to it, which would solve the wall collision all together, or you apply some math and checks to know what input is not allowed and when to stop. nothing really dramatic, just need some brainstorming.

the trick on this package is the use of "set event target" action in the "watch input" state of the Input controller fsm. Basically, It directly broadcast the events then. Without "set event target", you would need to create transition events, and then use "send event" action, which creates more states, more work ( and we don't like that...)

Then the rest is very simple, I added a speed factor on the "movement controller" so that you can control speed live ( pac man would be able accelerate as the level gets more complicated for example).


 If you have any question, let me know!

 Bye,

 Jean

lordnovas

  • Playmaker Newbie
  • *
  • Posts: 4
Re: How would I make a Pac Man like movement with Playmaker?
« Reply #5 on: April 06, 2012, 01:39:52 PM »
Hey Jean,

Thanks a bunch man, after looking at your setup I was pretty far off yesterday. This is exactly what I was going for and you showed me some great things in Playmaker. Send Target Event complete with broadcast all is very clever, it makes me realize how lego like playmaker is. Very cool and now I'm starting to understand this awesome tool.

Solved!

Thanks a bunch Jean,
Cheers,
ln

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: How would I make a Pac Man like movement with Playmaker?
« Reply #6 on: August 29, 2017, 12:44:48 PM »
Hi,

 Here we go, attached a unitypackage with a packman you can control with the arrow keys.

 The next step would be to define how you intend to work out the pacman behavior as it hit walls, and for this several solution are possible, either you switch to full physics and instead of translating, you apply force to it, which would solve the wall collision all together, or you apply some math and checks to know what input is not allowed and when to stop. nothing really dramatic, just need some brainstorming.

the trick on this package is the use of "set event target" action in the "watch input" state of the Input controller fsm. Basically, It directly broadcast the events then. Without "set event target", you would need to create transition events, and then use "send event" action, which creates more states, more work ( and we don't like that...)

Then the rest is very simple, I added a speed factor on the "movement controller" so that you can control speed live ( pac man would be able accelerate as the level gets more complicated for example).


 If you have any question, let me know!

 Bye,

 Jean


Hi!
I know this post is very old, but I just want to say that I have tried so many times to get the pac man controller to work. I downloaded your example, Jean, but the only help I got from the example was the controller. Much better than the one I used. But the good news are that I finally solved it, using Raycasts to detect the walls. Because Pac Man controller is like, when I move to the right, and then I click the up button, Pac Man automatically moves up in the first opportunity.

I can upload the file. Maybe it can be useful for somebody. :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How would I make a Pac Man like movement with Playmaker? [SOLVED]
« Reply #7 on: September 04, 2017, 03:22:42 AM »
Hi,

 Cool. Yes please share, the community will always appreciate contributions.

 Bye,

 Jean

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: How would I make a Pac Man like movement with Playmaker? [SOLVED]
« Reply #8 on: September 04, 2017, 01:05:15 PM »
Hi!
You can download the file here. :)

I appreciate if I can get some feedback of the pac man controller and suggestions to make it better. I use Raycast to check if there is a wall or not, so if the speed of pac man is too high, the Raycast doesn't always register. I don't know how to fix this.

http://hutonggames.com/playmakerforum/index.php?topic=15708.msg73004#msg73004
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no