I am trying to make a day-cycle with the sun going up and down with code.
(I am very new to UE so this may be a “noob”-question).
I want to access the “Directional Light” actor (in “World Outliner”) that is already placed in the editor (by default) with c++ code.
I want to do this because after my understanding this actor is the “sun”.
Can someone please tell me how I can start editing the settings for the Directional Light with code? Or Is there another way one should edit the sun to rise/set maybe?
You’ll need to define a actor class in C++. Then add a property that takes in a directional light.
After you compile and launch the editor, you can place this actor on the scene. Select this actor and you’ll see the directional light property you created earlier. It will be null by default. Assign the active scene’s default directional light
class GAME_API AMySunManager : public AActor {
public:
UPROPERTY(EditAnywhere, Category="Sun")
ADirectionalLight* Sun;
public:
virtual void Tick(float DeltaSeconds) override {
if (Sun != nullptr) {
//move the sun
}
}
};