Keep UseAbility run after disable input?

Kirshor

Member
Use Ability will be forced to stop after call:
EventHandler.ExecuteEvent(m_Character, "OnEnableGameplayInput", false);
I want the UseAbiility still keep running after disable input. What should I do?
 
For this you can subclass the Use ability and then override the OnEnableGameplayInput method. I'll make it protected so you won't have to keep updating the method signature.
 
I tried another way to prevent players from moving and rotate from the input. Is it safe to use it?

mLoco.MotorAcceleration = Vector3.zero;
mLoco.RootMotionSpeedMultiplier= 0;

m_HorizontalLookInputName = "";
m_VerticalLookInputName = "";
 
No, that doesn't look very safe to me. Justin's recommendation for a custom Use ability is a good one. Here's a basic example of it:

C#:
using Opsive.UltimateCharacterController.Character.Abilities.Items;

public class UseCustom
{
    public override void OnEnableGameplayInput(bool enable) {
        // You can just leave this empty so that nothing will change at all when input is enabled/disabled,
        // or you could put any other custom code in here.
    }
}

You'll get an error when compiling that, because Use.OnEnableGameplayInput is private - so go into Use.cs and change private void OnEnableGameplayInput(bool enable) to protected void OnEnableGameplayInput(bool enable). As Justin said, this change should get added to the next UCC update anyway so you won't have to worry about it after that.
 
Top