Playmaker Action Request - UCC Character Is Grounded

hazuki

Member
Hi,

Would it be possible to get an action for something like this but for UCC?
1418


This is the code for the above for reference:

Code:
// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved.

using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
    [ActionCategory(ActionCategory.Character)]
    [Tooltip("Tests if a Character Controller on a Game Object was touching the ground during the last move.")]
    public class ControllerIsGrounded : FsmStateAction
    {
        [RequiredField]
        [CheckForComponent(typeof(CharacterController))]
        [Tooltip("The GameObject to check.")]
        public FsmOwnerDefault gameObject;
        
        [Tooltip("Event to send if touching the ground.")]
        public FsmEvent trueEvent;
        
        [Tooltip("Event to send if not touching the ground.")]
        public FsmEvent falseEvent;
        
        [Tooltip("Store the result in a bool variable.")]
        [UIHint(UIHint.Variable)]
        public FsmBool storeResult;
        
        [Tooltip("Repeat every frame while the state is active.")]
        public bool everyFrame;
        
        private GameObject previousGo; // remember so we can get new controller only when it changes.
        private CharacterController controller;
        
        public override void Reset()
        {
            gameObject = null;
            trueEvent = null;
            falseEvent = null;
            storeResult = null;
            everyFrame = false;
        }

        public override void OnEnter()
        {
            DoControllerIsGrounded();
            
            if (!everyFrame)
            {
                Finish();
            }
        }

        public override void OnUpdate()
        {
            DoControllerIsGrounded();
        }
        
        void DoControllerIsGrounded()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);
            if (go == null)
            {
                return;
            }
        
            if (go != previousGo)
            {
                controller = go.GetComponent<CharacterController>();
                previousGo = go;
            }
            
            if (controller == null)    return;
    
            var isGrounded = controller.isGrounded;

            storeResult.Value = isGrounded;

            Fsm.Event(isGrounded ? trueEvent : falseEvent);
        }
    }
}
 
For this you should be able to use Playmaker's GetProperty task on the Ultimate Character Locomotion component. This will allow you to get a wide range of properties without needing a custom task.
 
Thanks, this is how I currently have it set up and it does work for me, but I have read that using Get and Set Property should be avoided if possible as those actions use reflection and on some platforms then can cause issues that force you into using Playmaker's Linker Wizard which is a real massive pain. https://hutonggames.com/playmakerforum/index.php?topic=11126.0

I'm happy enough to use it, but others might run into problems, in a previous project using Get and Set Property on Nintendo Switch builds caused some big headaches. It's probably why some assets with PM integration have a huge suite of actions even though you could just use those Get/Set property actions.

Thought you might not be aware of the potential issues so just wanted to let you know. thanks!
 
Top