playMaker

Author Topic: Help with my Movement FSM  (Read 363 times)

shackener

  • Playmaker Newbie
  • *
  • Posts: 1
    • View Profile
Help with my Movement FSM
« on: December 21, 2018, 02:48:17 AM »
Hi guys,

I recently started using PlayMaker without too much of a coding/scripting/visual scripting background. Today I started to create a movement fsm with the intention of making a spaceship move. That means I slapped a rigidbody on the ship and made an fsm which moves it using acceleration force applied when a key is pressed using the standard wasd structure.



My problem here is that I wanted to add states where both W & A were pressed for example and that part works, but there is a bug (at all double key pressed states) whereas if I press A & W for example in rapid succession but releasing them as soon as pressed, it acts like the first key pressed is still being pressed without any key being down mean the while.

In practice it looks like that if I press and release A & W (or any other combination) very quickly, most of the times instead of going back to the waitingForControl state it goes back to the aPressed state, meaning that the ship is moving sideways even though I'm not pressing anything. It literally stucks. I feel very dPressed by not knowing what I'm doing wrong.

I attach the unitypackage according to the sticky thread instructions if you'd like to take a look at my mess: https://drive.google.com/file/d/1XVSuZqoZy05GVQtTh0qi4eqpirs-w8FS/view?usp=sharing

I appreciate your help!

Thank you

agelvik

  • Beta Group
  • Playmaker Newbie
  • *
  • Posts: 23
    • View Profile
Re: Help with my Movement FSM
« Reply #1 on: December 21, 2018, 03:27:26 AM »
hey,
i actually use similar movement for my player controller in my game atm, here's my setup:


i separate horizontal and vertical movement between 2 fsms which gives me the 8-directional movement effect. i use the actions "get key" and "bool test" here, but it uses "every frame" so might want to be careful.. i use it cus i want it to be 100% reliable at all times since it's the player controller.


at the same time this system lets me easily rotate the player visually using "set fsm bool"... in case i want him to rotate 45 degrees according to the direction he moves in :)


hope it helps

Thore

  • Sr. Member
  • ****
  • Posts: 342
    • View Profile
Re: Help with my Movement FSM
« Reply #2 on: December 22, 2018, 04:50:15 AM »
Hi, consider dedicated 8-way input actions like this one:

https://hutonggames.com/playmakerforum/index.php?topic=4516.msg60524#msg60524

You can also toy around with my movement action (when you use both axis, you can try switching on has neutral on both): https://hutonggames.com/playmakerforum/index.php?topic=19504.0

Finally, my usual comment: unless it’s really a small game just for the internet, or to debug quickly, do not use key down actions. Use the input manager, button down and the two axis (“horizontal” and “vertical”) as proper inputs. They are mapped to wasd by default, but also the arrow keys, controllers and gamepads.

Try the 8 directional one above. If you want something more atomic, try my axis-down-to-button, here: https://hutonggames.com/playmakerforum/index.php?topic=19499.0