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

**URL:** <https://forums.unrealengine.com/t/is-there-a-way-to-find-socket-coordinations-without-converting-fstring-fname/37705>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [August 6, 2015, 5:46am UTC](https://forums.unrealengine.com/t/is-there-a-way-to-find-socket-coordinations-without-converting-fstring-fname/37705 "2015-08-06T05:46:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![HInoue](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HInoue](https://forums.unrealengine.com/u/HInoue)\
**Post date:** [August 6, 2015, 5:46am UTC](https://forums.unrealengine.com/t/is-there-a-way-to-find-socket-coordinations-without-converting-fstring-fname/37705/1 "2015-08-06T05:46:11Z")

</div>

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:

```auto

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?

---

<div class="post-metadata">

**Author:** ![UnrealEverything](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@UnrealEverything](https://forums.unrealengine.com/u/UnrealEverything)\
**Post date:** [August 6, 2015, 7:55am UTC](https://forums.unrealengine.com/t/is-there-a-way-to-find-socket-coordinations-without-converting-fstring-fname/37705/2 "2015-08-06T07:55:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![HInoue](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HInoue](https://forums.unrealengine.com/u/HInoue)\
**Post date:** [August 6, 2015, 8:15am UTC](https://forums.unrealengine.com/t/is-there-a-way-to-find-socket-coordinations-without-converting-fstring-fname/37705/3 "2015-08-06T08:15:22Z")

</div>

…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. ^^
