Hello all,
I’m having trouble with a notifyState
I want to build a melee combat system (multiplayer), When I trigger a melee ability (with GAS), the ability play a given montage, which trigger a custom AnimNotifyState
void UAnimNotifyStateCanHit::NotifyTick(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float FrameDeltaTime, const FAnimNotifyEventReference& EventReference)
{
Super::NotifyTick(MeshComp, Animation, FrameDeltaTime, EventReference);
AMORPGCharacter* BaseCharacter = Cast<AMORPGCharacter>(MeshComp->GetOwner());
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, FString::Printf(TEXT("hit !")));
if (UKismetSystemLibrary::IsDedicatedServer(GetWorld())) {
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, FString::Printf(TEXT("i'am server !")));
}
if (BaseCharacter && HitLocation != EMORPGHitLocation::None)
{
FVector location;
switch (HitLocation)
{
case EMORPGHitLocation::FistLeft:
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, FString::Printf(TEXT("hit with left fist")));
location = MeshComp->GetSocketLocation("middle_02_l");
break;
case EMORPGHitLocation::FistRight:
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, FString::Printf(TEXT("hit with right fist")));
location = MeshComp->GetSocketLocation("middle_02_r");
break;
default:
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, FString::Printf(TEXT("this should not happen")));
location = BaseCharacter->GetActorLocation();
break;
}
UKismetSystemLibrary::DrawDebugSphere(GetWorld(), location, 150.0f, 10, FColor::Red);
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, FString::Printf(TEXT("hit at %s"), *location.ToString()));
TArray<AActor*> OutActors;
FHitResult OutHit;
TArray<TEnumAsByte<EObjectTypeQuery>> ObjectTypesArray;
ObjectTypesArray.Add(UEngineTypes::ConvertToObjectType(ECC_WorldDynamic));
/*
bool HasHitOne = UKismetSystemLibrary::SphereTraceSingleForObjects(GetWorld(), location, location, 500.f, ObjectTypesArray, true, {}, EDrawDebugTrace::ForDuration, OutHit, true);
if (HasHitOne) {
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, FString::Printf(TEXT("yeah")));
}
*/
bool HasHit = UKismetSystemLibrary::SphereOverlapActors(GetWorld(), location, 150.0f, ObjectTypesArray, APawn::StaticClass(), { BaseCharacter }, OutActors);
DrawDebugSphere(GetWorld(), location, 150.0f, 10, FColor::Red);
but the drawdebugsphere function never show on screen, no matter if I’m in standalone mode or multiplayer mode.
I get the first log message “hit!”, the second “hit with left fist” and the third one “hit at {location}”, the location seems good because when I move the caractere I can see the location changing. but the message “i’m a server” never show nor the debugsphere,
here is the anim montage screenshot
Is there something I could be missing ?
Can I rely on notify state like this or should I use something else ? I tried to use GAS gameplay cue where i see the debug sphere, but I don’t think GAS gameplayCue are designed to build such mechanism