Skip to content

GASAbility_TargetLock

Nyntex edited this page Feb 7, 2025 · 5 revisions

Inherits: UGameplayAbility
UCLASS Specifier: Abstract
The constructor initializes the ability to be instanced per actor, not replicating and being retriggerable.

This ability lets the given camera be rotated smoothly towards a target that gets chosen by the ability.
This ability is nothing more than a runner for the task. However, I wanted to encapsulate it in an Ability to use the task like any other ability.

Members

Publicity Type Identifier Initializer UPROPERTY Description
Protected UGASTask_TargetLock* TargetLockTask - BlueprintReadOnly
VisibleAnywhere
Category = "Ability | Target Lock"
The target lock task that is being run. Since the ability has no tick I used it to simulate the tick. It's exposed so you can see if it's set or not. Only readable in Blueprint because it's set in the ability and shouldn't be set from outside.
Public FStruct_TargetLockData TargetLockData - BlueprintReadWrite
EditAnywhere
Category = "Ability | Target Lock"
A configuration struct so the task and the ability can use the same data. This way the ability has all data exposed and only the struct must be changed in order for both the task and the ability to accept the changes.
Public bool IsLockingOnTarget false BlueprintReadWrite
EditAnywhere
Category = "Ability | State"
This variable is required for retriggerability of the ability. It is checked and set when the ability is tried to be run and will either end the ability or start it when retriggered.

Protected Functions

Type Identifier Parameter Description
virtual bool
const override
CanActivateAbility const FGameplayAbilitySpecHandle Handle,
const FGameplayAbilityActorInfo* ActorInfo,
const FGameplayTagContainer* SourceTags,
const FGameplayTagContainer* TargetTags,
FGameplayTagContainer* OptionalRelevantTags
Gets called when the ability is tried to be activated. This is the place where any checks for resources from attributes would take place but this ability does not consume any resources so it will always return true.
virtual void
override
ActivateAbility const FGameplayAbilitySpecHandle Handle,
const FGameplayAbilityActorInfo* ActorInfo,
const FGameplayAbilityActivationInfo ActivationInfo,
const FGameplayEventData* TriggerEventData
This actually runs the ability. If the ability was active before the task will get canceled and the Ability gets ended instead.
void OnTaskEnded This gets called when the task ends itself. This happens for example when the line of sight check fails or the target leaves the effective range.

Clone this wiki locally