Printing location

I could print X, Y, Z but i got a problem.

But something i couldnt undrestand:
When i wanted to print only the X value i was sayng Pos.X.ToString() but i got and error, it only brings back a float.

If anyone knows why, and how to get X and convert to string please tell me.

floats don’t have a .ToString() method. But you can log floats directly, you don’t need to convert to a string. Just use the %f format specifier instead of %s.

1 Like

Thank you, however i want to store the .X or .Y value inside a FString variable first and thats the problem for me :+1:

I just searched for “c++ float to string unreal” and it pointed me here: https://answers.unrealengine.com/questions/3716/convert-float-to-fstring-c.html

In your code: FString ObjectPos = FString::SanitizeFloat(Pos.X);

So you have to go from the FString class which has a converter for floats. I expect some things are like this: if the converter you are looking for isn’t on what you are converting FROM check and see if there is a converter on what you are converting TO. And in a pinch there is always google, stackoverflow, or answers.unrealengine.com :slight_smile:

2 Likes

O yeah, Thanks

Privacy & Terms