I want to create a simple controller for a character using w,a,s,d. The FSM will move forward by pressing "w", left by pressing "a", right with "d", and back with "s". The problem is that I cannot create an FSM that can move both forward and left (diagonally) because I can only be in one state at a time.
I created an FSM so from start state Listener I can press a key (w) and it will go to the move forward state which then translates the player forward by a certain speed. In order to return to the listener state I have "get key up" command to return and only then can I press "a" to move left. The problem is I cannot go forward and left at the same time because the FSM can only be in one state at a time.
In code this is easily done using Update function with four if statements:
function Update ()
{
if (Input.GetKeyDown ("w"))
{
transform.Translate(10, 0,0);
}
if (Input.GetKeyDown ("s"))
{
transform.Translate(-10,0,0);
}
if (Input.GetKeyDown ("a"))
{
transform.Translate(0, 10,0);
}
if (Input.GetKeyDown ("s"))
{
transform.Translate(0,-10,0);
}
}
So I can hit multiple keys at once and thereby move diagonally. I know this can be solved with a character controller with simple movement but I want to know if this concept is possible using PlayMaker because I can see other scenarios where this could apply.
Love Playmaker it is really a cool plugin and really want to develop with it. Thanks so much for your time.