First Person Gameplay Ability Support

This question was created in reference to: [Gameplay Ability System with multiple skeletal [Content removed]

I was hoping to get some further info what approach would be best to consider when making abilities that need to support multiple skeletal meshes which is the case when making a multiplayer first person game.

Right now it seems like the avataractors skelmesh is just cached through FindComponentByClass which means it can potentially pull any mesh that’s attached to the character?

At the moment I’m not sure at all what options are available so any help on the matter is appreciated.

Hello Stefan,

There’s a few approaches to this, depending on your needs you might need to use only some, or all, of these.

Here’s a high level view:

Using animation blueprints (ABP) is a good way to ensure animation logic can play on two different Skeletal Meshes (SM) at once, even though gameplay abilities only keep one SM reference at a time.

In your hierarchy, you can select your SM and select “use animation blueprint” and assign an ABP.

This way, instead of having all your abilities call their respective animations, the ABP can grab the state of the character and use logic you set up in order to play the right animation.

For the third person mesh, you can grab the player actor by using TryGetPawnOwner in the ABP BeginPlay, and from there determine the player speed, if they’re grounded, etc. These values can then drive the currently playing animaton. You can do the same thing for the first person mesh, and read in the same values.

Using delegates can also help with values that aren’t constantly changing, and only change occasionally.

For example, if your player has an inventory component, you can create a bindable delegate which is called whenever the player swaps which item is in their hands. Then, your first person ABP can bind to the delegate and always have an up-to-date ref to the current item and play the correct animations.

If you want your Gameplay Abilities (GAs) to fire animations on both your 3rd person and 1st person mesh, that can be done as well.

The first person mesh can be accessed within a GA if you:

1. Store an accessible reference to first person SM on your character actor

2. Use GetAvatarActorFromActorInfo to get a reference to your character actor, and then access the SM reference you made.

If you want something really generic, In the GA, you can also get component by tag to grab specifically tagged components.

Thanks for giving some examples.

I might be missing something but using any of those approaches would mean not using the AbilityTasks for playing animation right?

My solution right now is to kind of treat the first person mesh/animations as a visual addition that only plays on the local machine and manually interrupt them OnAbilityEnd etc. It would be nice with a solution that keeps all the useful stuff regarding replication that the ability tasks provide.

Am I misunderstanding your suggestions?

Ah, sorry I think I misunderstood your question. Are you only looking to replicate the third person mesh? Or are ther other meshes which you want to replicate?

In terms of built-in solutions, you have two options to play animations from a gameplay ability:

Firstly, PlayMontageAndWait, which grabs the character’s skeletal mesh, and reps it for all clients. However, this only works for the character’s mesh.

Secondly, For a mesh which doesn’t need to be replicated, you would use PlayMontageand pass in whatever skeletal mesh you want. Keep in mind this is not replicated, and you’d have to grab the mesh you want to animate from the actor manually.