point light blueprint for traffic lights?

Can someone please EILI5 (Explain it like i’m five) how to create a blueprint to control some traffic lights?
Ive seen images of the blueprint setups online but none of them seem to actually tell you where or how to set the node parameters etc.
For example;

this image. in the dynamic material instance node directly underneath it says ‘target is primitivecomponent’ how to i set that target?
also the element index and source material options dont appear in my node either.
What is the ‘light shape’ node to the left?
Can anyone help me out?
Jack

In your example the material of the actor component “Light Shape” is dynamically changed. This has nothing to do with point lights but emissive materials. Once I get home later today I can throw together a little example. You can also take a look here (the last three vids about dynamic material instancing).

There is an actual example of a BP traffic light in the Blueprint examples that comes with Examples Content, check it out.

oh ill take a look thanks! ive kinda got my head around how things work in the blueprint editor today. It still doesnt logically make sense to me that you cant just keyframe a light sequence and just set it to loop forever.

BP is visual programming, key word being “programming”. I believe we all have the ability to program, it’s a human trait, but it just takes some time to get it down. Keep plugging away at BP and you will get it!

I realize this is an old topic, but I am trying to create a traffic light for a level, and Have yet to find a good way to go about switching between the three lights. I checked a bunch of the content examples after seeing this, but have had no luck in finding the example you referred to. Do you know which one of the example content levels this was in?

Hey there,

i went ahead and did a small BP for this. Here is exactly what i have done.

  • Create a new Blueprint of type “Actor” and call it “TrafficLight”

Inside of this Blueprint:

  • Add the following 4 Components:
    – A scene and make sure it is the root and name it “DefaultRoot”
    – 3 Point lights and name them “RedLight”, “YellowLight” and “GreenLight”

This has to look like this:

  • Select the YellowLight and move it in the Viewport a bit over the green one.
    – Also move the red one over the yellow one.

(NODE: This is just for testing. You can place them in your model or something later on)

  • Now select each of it (one after another) and look at the settings on the right side.
    – Change the “Light Color” under “Light” to the matching color.
    — So RedLight → red, YellowLight → yellow and GreenLight → Green.

We are starting with the RedLight on, so make sure you select the yellow and green one (one after another) and scroll down in the options
until you find to section “Rendering”. Make sure “visible” is NOT checked for both of them.

  • Now, click on “Add New” in the main Editor Window where you also added the Blueprint.
  • Go to “Blueprint” and select “Enumeration”, because we want to use a little state system.
  • Name it “TrafficEnum”.

http://puu.sh/gIUmh/8276cb984a.png

  • Create 4 new entries by clicking on “New” on the top right corner and name them like i did:

  • Now go back into your Traffic Light BP and open up the Event Graph.

  • Here we want to create 2 things.
    – First you want to create a new function.
    – Call it “GoToNextState” ← exactly like this. Leave it for now.

  • Then create a variable and call it “State”.
    – For the type, search for “TrafficEnum”, which is the Enumeration we created earlier.
  • Save and compile your BP and make sure the default value is “Red”:

  • Now, in you Event Graph, if you don’t have a node “Event Begin Play” already placed in it, right click and search
    for it.
  • After that, pull out the white arrow and release it on an empty spot. Now search “Timer” and select “Set Timer”
    in the context menu.

This should look like this:

  • If you clicked on it, you will have to click the “Looped” bool and write in a “Time” of 3 (for seconds).
  • Also we need a function name. Here we use our function called “GoToNextState”. Make sure you spell it the exact same way.

  • Now click on your function with that name and pull in your “State” variable.

  • Select “get” when the menu pops up.

  • Drag the pin of the state variable and release it on an empty space.

  • Search for “switch” and select the “Switch on TrafficEnum” node.

After that you should see something like this:

http://puu.sh/gIUNl/f6e97cb3e7.jpg

  • Now you just need to add the logic behind a traffic light. If we are in the “Red” state, the next state will be “RedYellow”, so now
    instead of getting the State variable, we want to set it.

  • Also get all 3 of the lights that you can find at the upper left side.

  • Pull one pin of the light of and release it on an empty space.

  • Search for “visibility” and select “set visibilty”.
    – With this you will turn your lights on and off.

I will only post you the picture of that last setup, because it is very easy once you have the nodes:

The Timer we used is just for testing. It will call the “GoToNextState” every 3 seconds throughout the whole GameSession.

You can call this function like you want. You could also use another switch for that state to implement different delays etc.

So this “small” tutorial took me a while, but i hope it helps you getting started (:

If you have any questions regarding this tutorial or the topic, feel free to ask me.

You are awesome! Thanks so much. Worked perfectly.

I’m glad i was able to help (: If you have more question, feel free to ask me

Ok, I do have one more question on this. I want to set the light up so the green and red lights would display for 30 seconds each. And the yellow light would display for only 15 seconds. When I tried to set it up, I was getting a lot of overlap with the lights coming on. What is the best way to set that up?

I will modify this to the state that you want. I will post it later. Need to finish some other things first (: stay tuned.

Hey,

so i updated the traffic light. You will want to create the following variables:

You can modify the default value of each variable on the upper right side in the details panel:

Now go to the Set Timer function and remove the tick from “Looping”. Also add the Start Delay variable like i do:

http://puu.sh/gKdJH/cd730365c6.png

In the function itself, you will want to create the following:

I used the “Red Delay” for Red AND RedYellow light. You can create an additional variable for that, but i thought you meant Red and RedYellow both as Red, so
i divided the 30 seconds by 2 and used the delay for both states. (: I guess you know how you can modify this.

Just make sure that both Set Timer nodes don’t loop!

Sorry for the late reply. My computer fried shortly after I asked the last question, so I had to wait until I could get a new one to try this out. It worked perfectly. Thanks again!

I have one more question, though. My mesh has three sets of lights on it. (3 groups of red, green, and yellow). Do I need to just duplicate this entire blueprint on the same one, or will I need a different graph for each of the three sets? Also, will I need three separate functions, or can I call the same one for each set?

Hm, why do you have 3 groups and not only 3 lights? And what are groups for you? Do you have multiple lights for red?

If all lights of one color do the same at the exact same time, then you can just plug them into the Set Visibilty nodes of the other red/green and yellow
lights that are already there (or create a new node for every light :X). You could also pack them into an array and go through the array, but that is just
a things of structure and organization.

If all lights of one color work seperatly from each other, then you need to wrike a function for each with the time you want.

There are three sets of lights because it is an overhanging traffic light for a multi-lane road. One lane is a turn lane, so it will run on a separate timer than the others. Thanks again for the help!

I dont know how you can modify that RedYellow delay.
So can you help me
**
EDIT: I figured it out.
Just change upper Red Delay to new variable RedYellow**

ok guys first of all thanks for this nice tutorial.
I have made the blueprint as shown in tutorial.
I am an artist who want to learn programming through blueprint system.
I am making a traffic system for my learning purpose in which there is a road a car and traffic signal. car will run in loop and behave it’s action according to the traffic light.

Thanks…

Can someone help me rerout this to Red|Green|Yellow|Red|- Loop? Please

eXi, man thanks a lot. Helped me with my issue as well!