Is there a way to find socket coordinations without converting FString>FName?

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?

It probably crashes because GetBodyInstance returns a null pointer if it can’t find that name you passed in (didn’t check in code but I’m assuming this is what happens). Since you’re working with the result without testing whether it is valid or not it then crashes unless the name was found.
Is there any reason for using FString over FName in your notify? This wouldn’t necessarily help with typos and the like but at least you wouldn’t need to convert to a name first.

…so I have no clue why I never thought of just making the FName accessible instead of the string, just doing that and checking GetBodyInstance make this a heck of a lot safer. Thank you for the eye! I never even noticed that I wasn’t checking the body instance. ^^