My character kept sliding a little when I used Get Axis and I wanted to use GetAxisRaw instead of GetKeyDown so that the user can use either the Arrow Keys or WASD.
// (c) Copyright HutongGames, LLC 2010-2011. All rights reserved.
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Input)]
[Tooltip("Gets the value of the specified Input AxisRaw and stores it in a Float Variable. See Unity Input Manager doc.")]
public class GetAxisRaw : FsmStateAction
{
[RequiredField]
public FsmString axisName;
public FsmFloat multiplier;
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmFloat store;
public bool everyFrame;
public override void Reset()
{
axisName = "";
multiplier = 1.0f;
store = null;
everyFrame = true;
}
public override void OnEnter()
{
DoGetAxis();
if (!everyFrame)
{
Finish();
}
}
public override void OnUpdate()
{
DoGetAxis();
}
void DoGetAxis()
{
var axisValue = Input.GetAxisRaw(axisName.Value);
// if variable set to none, assume multiplier of 1
if (!multiplier.IsNone)
{
axisValue *= multiplier.Value;
}
store.Value = axisValue;
}
}
}