Skip to main content
Version: 1.7.0

Using Triggered Interaction Cosmetic

Creating Triggered Interaction Cosmetic Ability

To create a Triggered Interaction Cosmetic ability, simply right-click in the Content Browser and select TwistedBytes | Abilities | Triggered Interaction Cosmetic as shown in the image below.

Name the newly created asset TriggeredInteractionCosmetic.

Create Triggered Interaction Cosmetic Ability

Setting up the Player Character

Open ThirdPersonCharacter, select TBIA Interaction Component. In the Details panel, add TriggeredInteractionCosmetic to the array named Grant Abilities on Start.

note

This will grant the ability to the ThirdPersonCharacter so it can be activated later on.

Create Triggered Interaction Cosmetic Ability

Creating the Interactable Actor

For an easier implementation, we are going to duplicate the GASActorBase that we created earlier in Using Interact Passive to make use of what we set up before. To do that, navigate to GASActorBase 1, right-click it and select Duplicate 2.

Name this newly created asset GASActor_Pickup.

note

We are going to create an item pickup object a player just needs to walk over in order to pick it up. Thus, when a player overlaps with GASActor_Pickup, it will activate the TriggeredInteractionCosmetic Gameplay Ability on that Player Character.

Create GASActor_Pickup

Open the newly created asset GASActor_Pickup. In the Components panel, click on Add Component 1 and add a Sphere Collision component 2 named Sphere.

After that, go to the Details panel of the Sphere and increase the value of the Sphere Radius property 3 to something around 150.

Setup GASActor_Pickup Collision

Now, right-click on the Sphere component 1, select Add Event 2 and choose Add OnComponentBeginOverlap 3 to add this event handler to the Event Graph.

Setup GASActor_Pickup Events

In the Event Graph you should now see the event handler OnComponentBeginOverlap. First, we want to cast the Other Actor variable to ThirdPersonCharacter and get the reference of its TBIA Interaction Component. From the component's reference we than need to get the ASCOwner reference.

Before continuing, we check if the actor is valid and then call Send Gameplay Event to Interacting Actor passing the following parameters:

  • Interacted Actor : ASCOwner 1
  • Event Tag : TBIA.Interaction.Triggered.Cosmetic 2
  • Interacting Actor : Blueprint Self reference.
note

ASCOwner is a reference to the actor holding TBIA Ability System Component which might be the Player Character or Player State depending on your project.

In our Demo Project we show how to get the ASCOwner reference using a BluePrint Interface which is a better (read: more performant) approach than casting. However, for keeping this tutorial concise and to the point we are using this shortcut instead.

From Event On End Interaction check if the interaction ended in normal execution, or it is being cancelled, then call Switch Has Authority and only if true we destroy GASActor_Pickup.

Setup GASActor_Pickup Send Gameplay Events

Testing the Interactable Actor

To test this interaction, place a couple of GASActor_Pickup in the level.

Test Interactable Actor

Press the Play button and let your player character overlap with GASActor_Pickup. You should see the pickup object getting destroyed.

note

As you can see, the ThirdPersonCharacter character played the Grab Montage that we set up earlier in Using Animation Cosmetic because we are using the same Interaction Context from GASActorBase.

Play in Editor