playMaker

Author Topic: GetAxisRaw Action  (Read 5889 times)

fimmfingur

  • Playmaker Newbie
  • *
  • Posts: 7
GetAxisRaw Action
« on: October 26, 2012, 06:07:30 AM »
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. 

Code: [Select]
// (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;
        }
    }
}


Jake

  • Junior Playmaker
  • **
  • Posts: 61
    • Fluffy Underware
Re: GetAxisRaw Action
« Reply #1 on: February 19, 2013, 02:39:17 PM »
Thanks, maybe this should be added as an option "Get Raw" to GetAxis and added to the official package...

krimson0

  • Playmaker Newbie
  • *
  • Posts: 10
Re: GetAxisRaw Action
« Reply #2 on: June 23, 2013, 01:19:10 AM »
Yes I agree to above, this would be very helpful in official as a option in get axis and get axis event

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: GetAxisRaw Action
« Reply #3 on: June 24, 2013, 03:22:44 AM »
Hi,

 you can adjust the input settings to avoid this. Simply remove all "gravity" for the given axis and the feeling will be sharper.

bye,

 Jean