Skip to content

Instantly share code, notes, and snippets.

@michaeltchapman
Last active July 18, 2018 04:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaeltchapman/c5d5b81bd3c2df606e744cacf1726ac4 to your computer and use it in GitHub Desktop.
Save michaeltchapman/c5d5b81bd3c2df606e744cacf1726ac4 to your computer and use it in GitHub Desktop.
// in AbilitySystemComponent child class
void UAsyncAbilitySystemComponent::SetCurrentMontageTask(UAbilityTask_MontageWithNotifies* MontageTask)
{
CurrentMontageTask = MontageTask;
}
void UAsyncAbilitySystemComponent::ClearCurrentMontageTask()
{
CurrentMontageTask = nullptr;
}
void UAsyncAbilitySystemComponent::NotifyCurrentMontageTask(FName Name)
{
// This will only fire on the predicting client and on the server since the montage task is not simulated
if (CurrentMontageTask)
{
CurrentMontageTask->OnNotifyNamed.Broadcast(Name);
}
AbilityNotifyDelegate.Broadcast(Name);
}
// in the montage play task Activate():
UAsyncAbilitySystemComponent* AASC = Cast<UAsyncAbilitySystemComponent>(AbilitySystemComponent);
if (AASC)
{
AASC->SetCurrentMontageTask(this);
}
// and in the Destroy():
UAsyncAbilitySystemComponent* AASC = Cast<UAsyncAbilitySystemComponent>(AbilitySystemComponent);
if (AASC)
{
AASC->ClearCurrentMontageTask();
}
// in new AnimNotify:
void UAbilityAnimNotify::Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation)
{
Super::Notify(MeshComp, Animation);
UAsyncAbilitySystemComponent* ASC = Cast<UAsyncAbilitySystemComponent>(UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(MeshComp->GetOwner()));
if (ASC)
{
ASC->NotifyCurrentMontageTask(NotifyName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment