Download

Component word location - inconsistency between BP and c++

Hello,

I Have a custom UBoxComponent in c++. I want to have the world location of that component.

If I use GetWorldLocation on a BP, it works fine.
If in the c++ class itself I use GetComponentLocation() it will always return relative location.

Any idea what can cause that? This behavior is quite inconsistent because both (based on documentaiton) are supposed to return world location.

Thanks in Advance!

Oh ok I debugged a little bit. It doesnt seems that I could even change the Relative location in C++. It seems location is not getting updated in c++

Just use the same function that blueprints use:

Mesh->K2_GetComponentLocation()

I tried that too. The problem seems to be that location is not getting updated in c++ and I can not even change it

GetWorldLocation is just the Blueprint name for GetComponentLocation(), the same code runs in both cases so they do exactly the same (namely return the world location of the component). If you share the actual code that you use maybe someone can tell you what the issue really is.

“solved” - it was just my brain freeze. My debugging was off. It returns the correct location, the way I was tracking it was just not correct. I just output the location at the wrong time just before the location got updated.