Get the world coordinates for actor

This must be a stupid question but I really cannot get the correct coordinates…I keep getting (0,0,0) with whatever I use.

Basically, I have a C++ Actor , which I added as component a StaticMesh, and made it root.

I created a variable ‘StartPosition’ which I made visibleAnywhere, and I defined it in constructor with:


StartPosition = myMeshPlane->GetComponentLocation(); // doesn't work

GetActorLocation doesn’t work either…

How can I retrieve correct coordinates?

Thank you!

could you add more of the code? this one line is correct so the problem is not here

Thanks for replying, I wanted to get the actor position in the world when adding the object from the editor, and moving it / scaling it etc. I confused the ‘Constructor’ from blueprint with the ‘Constructor’ from C++.

Equivalent of Constructor from blueprint seems to be onConstruct , which also has the FTransform of the Actor which gives me the world location!

edit: So I am guessing the constructor is called just before placing the actor into the world? And then the onConstruct keeps getting called whenever the slightest modification to object is done?

ahh ok well glad you found it