Use an Object from the World in c++

I just learned how to use UPROPERTY(), but now I have a problem.

105608-tmp1.png

Here I have a PointLight instance (placed in the world
In an actor, I want to use this instance of PointLight. I want to set it dynamically through the unreal editor, so I set this into the actor

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Light Config")
		UPointLightComponent* Destination;

But now, when I try to point in the editor to the specific pointlight, this happens

105609-tmp2.png

Instead of all the pointlights that I have in my world, there is only the option to instanciate a new one.
Does anybody knows what I’m doing wrong?

The pointlight you’re looking for is an actor in the world, so having a pointer to a UPointLightComponent will only work for components locally inside of the actor that you’re working in.

Try changing your pointer from a UPointLightComponent to a APointLight. Then it might come up, then access the component from there using APointLight->FindComponentByClass.

Thanks for your fast answer. I finally made a new actor which contains a PointLight, changed the UPointLightComponent to the new actor and managed it like this :slight_smile:

Awesome! Glad it worked out for you.