Hello, I’m having trouble replicating a custom event.
If I replicate the event on client, it crashes the engine. If i set the event to not be replicated, it only works on the server.
Here’s where i try to call the event:
Hello, I’m having trouble replicating a custom event.
If I replicate the event on client, it crashes the engine. If i set the event to not be replicated, it only works on the server.
Here’s where i try to call the event:
Looks like you’re using GAS? I personally wouldn’t use RPC’s within an ability as I’m not entirely sure how exactly that would scope? If you want to trigger a UI cooldown animation you can write a function that gets the cooldown of a specified ability tag, assuming you actually commit a cooldown in the ability. I have this code in an old project that I’m pretty sure I came across somewhere online.
bool AGASCharacterBase::getCooldownRemainingForTag(const FGameplayTagContainer CooldownTags, float& TimeRemaining, float& CooldownDuration)
{
if (AbilitySystem && CooldownTags.Num() > 0) {
TimeRemaining = 0.f;
CooldownDuration = 0.f;FGameplayEffectQuery const Query = FGameplayEffectQuery::MakeQuery_MatchAnyOwningTags(CooldownTags); TArray< TPair<float, float> > DurationAndTimeRemaining = AbilitySystem->GetActiveEffectsTimeRemainingAndDuration(Query); if (DurationAndTimeRemaining.Num() > 0) { int BestIdx = 0; float LongestTime = DurationAndTimeRemaining[0].Key; for (int Idx = 1; Idx < DurationAndTimeRemaining.Num(); ++Idx) { if (DurationAndTimeRemaining[Idx].Key > LongestTime) { LongestTime = DurationAndTimeRemaining[Idx].Key; BestIdx = Idx; } } TimeRemaining = DurationAndTimeRemaining[BestIdx].Key; CooldownDuration = DurationAndTimeRemaining[BestIdx].Value; return true; }
}
return false;
}
I’d link the source but I honestly don’t remember where I got it from.
Your target widget can just query that function with the appropriate tags you want the cooldown for and apply outputs to your (im assuming) material mask.
Hi!
I think this approach could work for my use case, but slightly modified given that i already have a function to get the CD Duration. My quiestion at this point would be where to call this from? from the gameplay ability once committed, or somewhere else?
I would call it from whatever needs the information? My implementation was in an RPG setting where you had a typical action bar, each individual skill that was on my bar would query their appropriate tag. I integrated it on tick originally, but on reflection that probably wasn’t the best idea.