Very new to Unreal Engine and playing with the Day Sequencer plugin as I was naively hoping it would be a nice easy route as a day cycle sequence to turn streetlights on and off. Has anyone had any luck getting this to work?
I realise this is an experimental feature, and I’m loving it but trying to figure out how to use it as a reference in the level blueprint to affect a turn on/off on a streetlight blueprint. Hoping that a much brighter and experienced person might be able to help!
Disclaimer 1: I don’t use the plugin, I just opened the docs at Day Sequence Time of Day Plugin for Unreal Engine | Unreal Engine 5.5 Documentation | Epic Developer Community (and the source on github) and hopefully figured out what to do, or at least something to start with.
Disclaimer 2: Unfortunately there doesn’t seem to be an event-based solution for this, the “time of day changed” delegate isn’t exposed to BPs, but just doing it in Tick will be fine (read on).
I’m assuming you added a ADaySequenceActor (of some kind) to your world (if not, check the docs, should be straightforward to set up a basic day/night cycle). I’m also assuming your streetlight is a blueprint asset and you know how to toggle its light on/off.
Create a BP to manage the streetlight toggling, either a new one or a derived ADaySequenceActor (if you’re not directly adding one of the premade ones). Doesn’t matter much which BP you use for the (following) logic, as long as you don’t make each streetlight tick on its own to achieve this (that’d be kinda wasteful and is easily avoided).
In that BP (let’s call it BP_StreetlightManager) connect your BeginPlay event to a GetActorOfClass node, and set ADaySequenceActor as the Actor Class (on that same node). Drag the resulting wire (blue) into a Cast to ADaySequenceActor node, and drag that result into “Promote to variable” (top of the dropdown), let’s call the variable StreetlightManager. This way you can easily reference the day/night cycle actor within this blueprint.
In that same BP, connect your Tick event to StreetlightManager->Get Time Of Day. This returns a float representing the current time of day, check the docs for more details if unclear.
Add a GetAllActorsOfClass node (connecting 3.'s white execution pin to this to continue the logic) and set your streetlight BP class as the “Actor Class” parameter. Drag the output array (blue wire) into a For Each Loop. Drag the loop’s blue wire (Array Element) into a Cast to BP_Streetlight (<- example name, use your streetlight BP’s name here). Manipulate the resulting wire using the time of day float (from step 3), either by directly accessing its components or by calling a function (you add to your streetlight BP).
Add BP_StreetlightManager (or however you end up calling it) to your world and it should automatically manipulate the streetlights (in whichever way you set up the logic at the end of step 4).