playMaker

Author Topic: IS there a better way to set up movment WASD  (Read 3123 times)

Saputo

  • Full Member
  • ***
  • Posts: 107
IS there a better way to set up movment WASD
« on: April 17, 2013, 05:46:12 PM »
the way mine is set up it's kinda broken lets say I'm holding down S (Down) then I want to go Left so I hit A (Left) it's wont read it unless I let go of S, and then press A again for it to register, does anyone know of or have a better set up, with screen shots? and I cant use Simple Move,b.c  it has gravity,and my char wont move or walk with that on, it's 2D, on a 90 degree angle.

So I have to use Controller Move, to make this work.

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3985
  • Official Playmaker Support
    • LinkedIn
Re: IS there a better way to set up movment WASD
« Reply #1 on: April 17, 2013, 06:31:05 PM »
Are you using Get Axis? You can setup controls in the Unity Input Manager. It gives you a lot more control over the input than the lower level actions like Get Key Down etc.

Saputo

  • Full Member
  • ***
  • Posts: 107
Re: IS there a better way to set up movment WASD
« Reply #2 on: April 17, 2013, 07:27:22 PM »
Nope I'm not using get Axis, look at it right now, well how would this work, b.c I use get Key Down for the Animations to play as well.
« Last Edit: April 17, 2013, 08:07:33 PM by Saputo »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: IS there a better way to set up movment WASD
« Reply #3 on: April 17, 2013, 08:23:31 PM »
If you must use your current method then make two FSM's

One to handle WS and one to handle AD. Neither can be run simultaneously (W&S or A&D) so the segregation is fine. It's a cheap fix.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: IS there a better way to set up movment WASD
« Reply #4 on: April 18, 2013, 09:29:56 AM »
Saputo sent me his files to mess with and I wanted to post the changes feedback here in case others are having trouble with it.

I changed a lot, the main idle controller now reads a set of bools and also waits for input, if there is none then it stops the animation and character speed.

It isn't necessary to use a unique event transition for every event. You can create a generic one and use it on any state.

The only two real states are Walk and Run so there is an input for each direction(4) and each has a run state(4 more). In all of them the Up Key returns to the idle state that checks to see the status of all keys and export to a bool which pushes to the appropriate direction states..

So if you are press A, then D, you're walking left and when you release A it sends the return back to idle, which checks to see if any other keys are down and when it see's that D is pressed it will move into the D walk state instead of stopping like the bottom of the idle state tells it to do. I like this style, personally. Didn't thoroughly test it out though.

If you want it to change direction while moving without letting a key go then I would probably copy the bool checks (from the Idle state) over to each direction state so they can see if any other key is pressed and if so then it goes to the idle state - which will check them all by default so you don't need wires from every state to every other state to transition, you have a manager state in the center to handle that now.

If you don't like that idea then you need a separate FSM that the manager is in and have it send events to decide which direction to go in so you can do the two simultaneously. This is a little more complex but will work well if you nail it.

Also the Walk/Run exit states you were using were very confusing with the float compares. Check out how I changed the process in general and use the Idle Manager state in the center with Get Key's and Bool Tests.

Your next problem is including run when the direction is changed. =) For that I would suggest looking at using a float for the direction value and managing it on another FSM so you can change it without interrupting the controller.
« Last Edit: April 18, 2013, 09:37:30 AM by Lane »
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Saputo

  • Full Member
  • ***
  • Posts: 107
Re: IS there a better way to set up movment WASD
« Reply #5 on: April 18, 2013, 08:35:56 PM »
it works great now, even added in some mods to it myself,workout very nice.