Is there a way to run FindComponentByClass in an animation notify without crashing persona?

I have a quick blot of code meant to run during the start of an attack animation’s notify, to let the combat system know that it should start drawing debugspheres to show the attack’s hitboxes:


void UHitframeNotifyState::NotifyBegin(USkeletalMeshComponent * MeshComp, UAnimSequenceBase * Animation, float TotalDuration){
	ULexicon* myLexicon = MeshComp->GetOwner()->FindComponentByClass<ULexicon>(); //Find the Lexicon component on the character running this animation
	if (myLexicon != nullptr) //If that component exists...
		myLexicon->showBoxes = true; //Tell it to start visualizing hitboxes
}

It works perfectly when I run the game, but if I try to open persona without commenting this code out, UE4 crashes. I’m assuming the crash occurs because my NotifyBegin runs in persona, but doesn’t have a component to find and point at, but having to comment my debugging code out every time I want to edit an animation is super-inconvenient: is there any way to either flag this to only execute in-game, or alter it to prevent the crash from occuring in the first place?

In personna there is neither Pawn nor Character, Personna generate a SkeletalMesh at runtime so MeshComp->GetOwner() will return nullptr

Try this :

if( nullptr != MeshComp && nullptr != MeshComp->GetOwner())
{
ULexicon* myLexicon = MeshComp->GetOwner()->FindComponentByClass<ULexicon>(); //Find the Lexicon component on the character running this animation
if (myLexicon != nullptr) //If that component exists…
myLexicon->showBoxes = true; //Tell it to start visualizing hitboxes
}

Hmm, this compiles, but I’m afraid it doesn’t remedy the persona crash.