If-Else Logic With Abilities

Solitary Forge

New member
Hi ,
With ,
private void OnAbilityActive(Ability ability, bool activated)
{
Debug.Log(ability + " activated: " + activated);
}
I got to know the Current active Ability, How can I use a If-else Logic with it, since "ability" is of type "Ability"

Basically , My main Aim is to increase the Radius of the Sphere Collider , when the Player Runs, and reduce the Radius , when it Crouches
 
All abilities have the IsActive variable, so you just need to get a reference to the ability first, e.g.:

C#:
var locomotion = GetComponent<UltimateCharacterLocomotion>();
var speedChangeAbility = locomotion.GetAbility<SpeedChange>();
var heightChangeAbility = locomotion.GetAbility<HeightChange>();

if (speedChangeAbility.IsActive) {
    // do something
} else if (heightChangeAbility.IsActive) {
    // do something else
}
 
All abilities have the IsActive variable, so you just need to get a reference to the ability first, e.g.:

C#:
var locomotion = GetComponent<UltimateCharacterLocomotion>();
var speedChangeAbility = locomotion.GetAbility<SpeedChange>();
var heightChangeAbility = locomotion.GetAbility<HeightChange>();

if (speedChangeAbility.IsActive) {
    // do something
} else if (heightChangeAbility.IsActive) {
    // do something else
}
This Code Snippet is Extremely Helpful!! , Thanks for your Help
 
Top