Stop useAbility while moving and prone simultaneously

I'm having an issue with deactivating useAbility while both moving prone. I recently made a prone ability that is pretty much the same script as the height change ability. While in-game, players should only be able to shoot their weapon from the prone position while not moving. Once the player moves, the ability to shoot is deactivated. With this script, I thought I would be able to do just that. However, the player is still able to shoot and move while the prone ability is active. Is there something I'm doing wrong? Here is the script:

C#:
public class M4A1ProneAndAim : MonoBehaviour
{
    [SerializeField] protected GameObject m_Character;
    [SerializeField] protected GameObject m_Item;
    [SerializeField] protected GameObject m4A1;

    private void Update()
    {
        var firstPersonPerspectiveItem = m_Item.GetComponent<FirstPersonPerspectiveItem>();
        var characterLocomotion = m_Character.GetComponent<UltimateCharacterLocomotion>();
        var useAbility = characterLocomotion.GetAbility<Use>();
        var heightChangeProneAbility = characterLocomotion.GetAbility<HeightChangeProne>();

        if (characterLocomotion.Moving && heightChangeProneAbility.IsActive)
        {
            characterLocomotion.TryStopAbility(useAbility);
        }
    }
}
 
You should probably just disable the ability instead. You can use Ability.SetEnabled(false) to do this.
 
Top