Playmaker Forum

PlayMaker Updates & Downloads => Share New Actions => Topic started by: fimmfingur on October 26, 2012, 06:07:30 AM

Title: GetAxisRaw Action
Post by: fimmfingur 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;
        }
    }
}

Title: Re: GetAxisRaw Action
Post by: Jake 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...
Title: Re: GetAxisRaw Action
Post by: krimson0 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
Title: Re: GetAxisRaw Action
Post by: jeanfabre 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