How to set an object'DirectionalLight' variable with an object'DirectionalLightComponent' in a blueprint

I am making a blueprint that contains DirectionalLight and BP_Sky_Sphere. BP_Sky_Sphere contains an editable variable called “Directional light actor” of type DirectionalLight. I cannot get a valid reference into that variable!

I’ve tried:

  • Basing my blueprint on BP_Sky_Sphere, dragging a setter on “Directional light actor.”
    • If I browse for the asset in the drop-down list, the list is empty.
    • If I drag my DirectionalLight component to the setter, it says, “object’DirectionalLightComponent’ is not compatible with object’Directional Light’.”
    • If I “Spawn Actor from Class” with the class of DirectionalLight, it connects to the setter, but the compiler fails with, “Literal values are not allowed for pass-by-reference parameters.”
  • Basing my blueprint off of Actor, I added BP_Sky_Sphere as a component by creating a variable of type BP_Sky_Sphere_C. Is that the correct way to add a blueprint as a component to another blueprint? I got the same errors.

I feel this is an issue of me not knowing how to get a reference to the instance that is in the variable. I just don’t know what else to try or read.

So again, I’m trying to set an object’DirectionalLight’ variable with an object’DirectionalLightComponent’ in my blueprint?

Thanks for any help you can provide.

I also need help with this one!

Here is my solution for the benefit of anyone else having the same question. You cannot put a DirectionalLightComponent into a variable of type DirectionalLight. DirectionalLight inherits from the Actor class and DirectionalLightComponent inherits from the Component class. If you have any object-oriented programming knowledge, you want to read the Unreal Architecture document that concisely describes how the whole system works.

1 Like

What solution did you engineer in the end? I’ve considered making the component a separate actor but I’d like to know what you achieved

a workaround for this is using “add child actor component” node in construction script instead of child component.
you can then make a variable that will store the child actor reference.

note: use “add child actor component”->“get child actor” for the actual child actor. the first node by itself is not enough.

I get the parent of DirectionalLightComponent (i.e. LightComponet), which helps me a lot.