Gameplay Cues without using a GCN/GCNA

You can use GameplayCues directly on an actor without needing to create a GameplayCue notify blueprint or a GameplayCue Actor blueprint.
This can be really powerful, allow you to manage specific cues either natively or directly in the actor/object’s blueprint.

Getting Started:

To get started, your actor or object receiving the cue MUST implement the following interface:
IGameplayCueInterface

class KAOSGAMECORE_API AKaosMoverPawn : public AKaosPawn, public IGameplayCueInterface

This interface has the following functions you can override:

  • virtual void HandleGameplayCue(UObject* Self, FGameplayTag GameplayCueTag, EGameplayCueEvent::Type EventType, const FGameplayCueParameters& Parameters);
  • virtual void HandleGameplayCues(UObject* Self, const FGameplayTagContainer& GameplayCueTags, EGameplayCueEvent::Type EventType, const FGameplayCueParameters& Parameters);
  • virtual bool ShouldAcceptGameplayCue(UObject* Self, FGameplayTag GameplayCueTag, EGameplayCueEvent::Type EventType, const FGameplayCueParameters& Parameters);
  • virtual void GameplayCueDefaultHandler(EGameplayCueEvent::Type EventType, const FGameplayCueParameters& Parameters);

These functions will be called on the interface (and thus the actor/object implementing it) so it can handle the cue (if it wants to).

ShouldAcceptGameplayCue

This can be used to determine if the actor/object should accept the cue or not. Reasons for not excepting a cue could be its a GameplayCue.Damage cue and the actor is dead, and you wish not to do anything.

HandleGameplayCue / HandleGameplayCues

These two functions will be called so you can handle a cue generically for the actor/object. You may wish to do forwarding logic here, maybe you activate a cue GameplayCue.Weapon.Activation and wish to forward it to the weapon the player is holding, so the weapon can handle the cue.

GameplayCueDefaultHandler

This will get called if nothing actually handles the cue. This will also be called if the cue was handled in HandleGameplayCue(s). This is called if no Blueprint Node or UFUNCTION was found to accept the cue.

Defining a Native Cue Handler.

To define a native cue handler is very simple. The important thing is, the function must be marked UFUNCTION. Example here:

	//Cue called when the pawn takes damage
	UFUNCTION()
	void GameplayCue_Damage(EGameplayCueEvent::Type EventType, FGameplayCueParameters Parameters);

void AAresPawn::GameplayCue_Damage(EGameplayCueEvent::Type EventType, FGameplayCueParameters Parameters)
{
//Cue logic here.
}

This function will match GameplayCue.Damage and all children, like GameplayCue.Damage.Elemental.Fire. You can get the original cue in Parameter.OriginalGameplayCue. Useful for doing different FX based on different damage type, etc.

Defining a Blueprint Cue Handler

You can make a blueprint cue handler, just by making an event in your blueprint graph, and putting the name as the cue you want to match, example here:

Forwarding Cues

I mentioned earlier you can forward cues, to do this, Epic has provided a function to forward to cues to another actor/object.

UAbilitySystemBlueprintLibrary::ForwardGameplayCueToTarget();

An example usage is like this:

void AAresGameplayActor::GameplayCue_Damage(EGameplayCueEvent::Type EventType, FGameplayCueParameters Parameters)
{
	if (HealthComponent)
	{
		UAbilitySystemBlueprintLibrary::ForwardGameplayCueToTarget(HealthComponent, EventType, Parameters);
	}

	if (GetWorld()->GetNetMode() != NM_DedicatedServer && !IsRunningDedicatedServer())
	{
		CreateHealthBar();
	}
}

This about wraps up this very short post. If you want more info or more help, check the contact me page. Can always find me on the Unreal Source Discord Server.