Issue with real time component location

I have an issue with the real time component location while using python. I have a blueprint with a component and i can be able to get the world location of it and when i try to print it to the screen, it is working. But when i set it to a variable(vector-public) and access it using python, it always returns the default value of the created vector variable.

Any way to get the real time world location of the ccomponent ?


Whenever i access i am getting the default value of the variable ‘camerafrontloc’. In this case it is a struct vector of (10,10,10). But the original location is different and it is correct when i print it to the screen !!

This is because you’re reading the variable from the default object.
You need a reference to the instance of the actor/component spawned in the world.
I don’t know the python lib but there has to be a way to get references to actors in the world.
Maybe something along the lines of

bp_car_camera = unreal.find_object(None, "PersistentLevel.Car_Blueprint_mod1");

This is a complete guess though.
You can see the name of the actor in world outliner, or print its name/path at runtime from blueprint.

Thanks for poinitng out the reason for not getting the location of the component. I am still searching and will update the post if i found a working method.

I figured out the way to get the location

bp_car = "PersistentLevel.Car_Blueprint_mod_5"
bp_ref = unreal.EditorLevelLibrary.get_actor_reference(bp_car)
car_location = bp_ref.get_actor_location()

As said earlier, with the reference we can access the parameters of the actor.