I have a function inside an animation notify state which draws a hitbox centered on a socket on the skeleton every tick. I need to be able to set the socket in the editor, since each attack needs hitboxes on different parts of the anatomy, right now I’m doing it by putting a public FString in the notify, then converting it at runtime:
FTransform UHitframeNotifyState::SetHitboxLocation(FString boneName, USkeletalMeshComponent* MeshComp){
FName convertedBoneName = FName(*boneName);
FTransform desiredLocation = MeshComp->GetBodyInstance(convertedBoneName)->GetUnrealWorldTransform();
return desiredLocation;
}
This works if and only if I feed it a name that actually corresponds to a socket. If I make a typo or give it complete garbage, the unreal crashes when it tries to find the socket. Is there a safer way of doing this, or a way to check the conversion for safety at runtime?