# Ways to simplify?

Hi!
As a training, I made a traffic light sequence blueprint yesterday.

It has Eastern European sequence, so it has 6 cases.

• 1 - red
• 2 - red yellow
• 3 - green
• 5 - yellow

It changes the case according to an integer timer, something like: “if 1000 > timer >= 1500 then case = 2”.
Every light has a boolean which is changed by the current case.
Also there’s a boolean “isWorking” which switches between case 0 and the other cases.

The sequence works perfectly but I guess the blueprint is a little too much big, which could result into annoying complications in a future.

Please, do you have any tips and suggestions how to simplify the blueprint? I’m not used to the UE4 programming yet and I don’t know, what everything it can offer.

Use arrays, enums, structs and variables.
For eg you can add enum that describes state of light.
Then you create struct that keeps color, boolean for blinking or not, time etc is single struct.
Then you can make array of structs. that describe every possible state of light.
And then you make function that fetches that data from array of structs when given enum with state.

Or you can do all above and use Finite State Machine plugin for unreal. It is even more fun that way.

for blinking etc you can use timeline or anim that animates color.
you can also make material with linearinterpolate beetwen 2 colors
then feed that material with color for blinking.

You got me thinking, this is nice problem.

you have 3 lights, you need to describe state of all 3 for each phase.
for each light you need 2 color variables:

• maximum color
• minimum color
For eg. yellow for blinking you set maximum to yellow, minimum to black
for yellow turned off, you set both to black
for yellow not blinking both set to yellow.

Then enum that describes blinking, light_on, light_off. and function that when given this enum and maximum color (like red green blue), gives out maximum and minimum color.
then you just feed results of that function to each light.

You are right, that is the simplest way.