How to get (x,y,z) values from a location or transform in C++

I know how to retrieve the x,y and z values from a vector in blueprints (you just break the vector into it’s multiple parts) but how do you accomplish this in C++? For example, I want to get the x-axis value of my game character in world space so I can get as far as:

GetTransform()->GetLocation()

which returns a FVector. But as far as I can tell I don’t see how to break this vector up and grab an individual axis value. Any suggestions? Thanks!

Just append a .(axis) to the value. For example,

MyVector.X

Will be the X value of the vector. The same works for angles, but with pitch, yaw, etc.

Actually, in general, if you append a → or . to an object (depending on if it’s a pointer or not), Intellisense will (sometimes very slowly) tell you the values and functions you have access to. Pretty useful for when you’re not sure what you’re looking for or if what you’re looking for exists.

3 Likes

Wow, so simple lol. Thank you very much.

this as answered please

1 Like