Cast to directional light not working

I’ve been messing around with the directional light (SunLight_Blueprint), but I can’t get it to even cast correctly. I have print strings attached to the output exec and cast failed exec, and it fails every single time. I created a variable called LightRef, which is the directionallight object reference, since directionallight was the parent class/blueprint of the sunlight_blueprint, but I’ve also tried Light Object reference and actor object reference as the LightRef variable as well just in case. I put it in event tick just for testing purposes. This is all in my game mode blueprint. My SunLight Blueprint is basic directional light converted to a blueprint, nothing is different from default becuase I’ve deleted and remade it several times to rule out something wrong with it itself. Let me know if you need any more pictures of something.

1 Like

How are you getting a reference to the actual actor in the level?

Typically you’d do Get all actors of class (Sunlight_Blueprint) → Get copy (0) → cast → Set Light Ref.

Furthermore you do the cast and set reference (light Ref) once using the Begin Play event. Then on Tick (every frame) use the reference variable to modify the light…

Just as an FYI you shouldn’t be hitting the directional light on Tick. Unless you are modifying it every single frame.

e.g. 60Fps would mean 60 modifications per second on that light.