How do I grant and activate a passive gameplay ability with data?

I have a minigame that I would like the player to interact with. The player interacts with the minigame, the server checks if the minigame can be used (not being used by someone else already), then grants a locally predicted gameplay ability to the user depending on what the minigame is.

I would like the granted gameplay ability to be activated on the player immediately, and I would like to query the minigame actor on the client while the ability is running to get certain data from it, such as, “what widgets should I activate, and what montages should I play?”

I can activate the ability in its OnAvatarSet function passively, but the problem is, I don’t know how to access the minigame on the client. If I set the minigame as a replicated property on the player before granting the ability, I have no guarantee that the client will have the replicated property when the ability is run.

It’s quite possible that I’m violating some principle that would avoid this issue entirely, but I’ve been stuck on this issue for a while so I would appreciate any help.

I’m answering my own question here. When giving an ability to an actor’s Ability System Component, you can specify a SourceObject.

From tranek’s unofficial GAS documentation, “Making the gun the SourceObject in the GameplayAbilitySpec when granting the ability means you’ll have access to the gun that granted the ability inside the ability.”

In my case, this allows me to access the minigame that granted my player gameplay abilities.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.