playMaker

Author Topic: Key Listener while Moving [SOLVED]  (Read 2357 times)

DanielThomas

  • Beta Group
  • Full Member
  • *
  • Posts: 150
Key Listener while Moving [SOLVED]
« on: July 25, 2016, 06:28:06 PM »
Hi!
So what I'm trying to do is get a grid based movement system, much like Grimrock or similar.

movement and collision is working fine, maybe not fancy but functional. What I want to add is, while the character is moving you can press the next movement key and it will automatically move next time. This is so you don't have to wait for the whole move-transition to the next grid/tile and THEN press the next movement key.

I'm not sure if this makes any sense, and I don't know what it's called. I just referred it to pooling for some reason.

Please see this image for the FSMs (not is wide, scroll to the right for comments):


So what is my problem? if I press W, he moves forward and everything works fine, but for some reason the second FSM (put keys in pool) catches the W key to be pressed as well. I don't know if I'm missing something in the actual logic or if there is something in how Unity/playmaker works.

And I don't understand why it wouldn't create an endless loop of moving forward, but only move twice every time I press W.

Am I missing something obvious?

Funny thin is that I thought I figured it out yesterday night and everything was working. Only to open up the project today and finding out I messed up somewhere while cleaning up the FSM  - and now I can't fix it.
« Last Edit: July 27, 2016, 02:26:30 PM by DanielThomas »

Chizzler

  • Junior Playmaker
  • **
  • Posts: 67
Re: Key Listener while Moving
« Reply #1 on: July 27, 2016, 01:55:07 PM »
In the first FSM (State: Check Keys), you've got the "Send Event" (to the Key Pool FSM) Before the "Get Key Down" Action, so both FSM's are listening for that key at the same time, hence the duplication.

Move the "Send Event" action to the beginning of your Movement states and it should solve the problem =)

DanielThomas

  • Beta Group
  • Full Member
  • *
  • Posts: 150
Re: Key Listener while Moving
« Reply #2 on: July 27, 2016, 02:26:18 PM »
Thanks!
But the event I'm sending to is "nothingKeyPool", which sets the FSM to do nothing.


BUT, this is super strange. I started unity today and now it WORKS. I don't know if there was some trash laying around in unity and it needed to be restarted. Exact same code, but now it works.

So atleast I wasn't just crazy :)

Consider this solved.