Making a Teapot Glow
For today's class we had gone through Unreal's Blueprints and programmed a teapot to glow red when a button was pressed.
Getting Started
Create a new empty basic level and create a folder to hold all of your objects and Blueprints.
Right click on the content browser and create a new Blueprint class. It's going to ask you to choose a parent class. Choose actor. Everything in Unreal that you see in the viewport and the player can interact with is called an actor.
 |
Popup that appears when you create a new Blueprint |
 |
The Blueprint tab |
With your new blueprint and inside the blueprint tab, go to the components subtab and make a new scene object. A scene object is like an empty group node in maya. It is used to hold other objects and allows them all to share the same pivot point. Drag in the meshes you wish to use. For us we had used a teapot with a lid. We also assigned the Burnish material from the starter content to the teapot and lid.
 |
Everything should spawn in at the origin of the Blueprint |
Event Graph
 |
Blank Event Graph |
Inside the event graph, you can drag an actor from the components tab and bring it as a node into the event graph. This creates a pointer to that object.
Event Tick Node
The event tick node will play every tick. A tick occurs every frame. Grab the Scene node that holds your objects and bring it into the event graph. Drag click on the output of this node, and type add local rotation axis. Whenever you drag from a input/output of a node, the nodes that show up are ones that would most likely apply to this output.
 |
Dragging from a node and releasing brings up this menu to look up new nodes to automatically connect to |
Go to the event tick node already in the event graph, drag the white arrow output to the white arrow input of the local rotate node. Now create a make rotator node, and plug in delta seconds to the z, and the return value to the delta rotation. Now compile and save.
 |
Nodes so far |
When we play the game so far with our blueprint. It doesn't look like our object is rotating. But if you look closely, it is rotating, albeit very slowly. This is because we are running at 60 frames per second, 1 second divided by 60 is 0.016667 (Note: the frames you are running at is dependant on your computer, so this can vary). We can actually check the exact value that the object is rotating at every second by creating a print node You will be troubleshooting Blueprints a lot, and the print string node comes in handy. Connect the string node with the Event Ticks node white output and delta seconds, and Add Local Rotation nodes white input. When you input the Delta Seconds to the in string input, it creates a new node that automatically converts the delta seconds from float to string. Now when you hit compile you can actually see the number of degrees it wants to rotate the teapot, which is 0.01667!
 |
Notice the colors of the lines connecting each node. Green appears to be a float data type, while pink seems to be a string data type
|
 |
The printed text will appear in the left area of the viewport when you start up the game |
Now we want to increase the speed of the rotation. We can create a multiply node and multiply the delta seconds by 25 Now every click is almost rotating half a degree , at 0.41666 (0.01667 times 25 is 0.416667). You can also use the print node to check the degrees the item is rotating after applying the multiply node.
At the end we can clean up our nodes and put a comment box around it by selecting the nodes and pressing c (similar to the material editor).
 |
The print string node is not necessary anymore, so you can delete them. |
Event Begin Play Node
The Event Begin Play only happens when the game starts and only once. When you want the game to listen to player input, you have to tell it to with the Event Begin Play node (why it doesn't do this automatically we don't know). Drag the white arrow from Event Begin Play, and look for enable input node. Then from the enable input>player controller input, drag it out and search for getPlayerController Node. Now it is listening for player input.
 |
Simple setup to listen for player input |
Getting Player Input
Next look for a keyboard g node to check when the g key is pressed. Create two print string nodes and put both the g pressed and g released outputs into both of them. Change what each string says (g pressed/released). Compile the BP and check the game to see if it worked.
 |
using the Print String node to debug |
 |
Pressing and releasing G will print this text to screen |
Setting up the Glowing Material
Now we want to duplicate the burnish material that we've assigned to the teapot (in the starter content) and name it M_MagicLamp_Template. Inside the material editor create a vector parameter and change the default color (this will be the color for the emissive color to glow). Create a scalar parameter (how much you want it to glow) and then multiply the two together and put it into the emissive material slot. Make sure you remember what you named the scalar parameter because this will be used in the blueprint.
 |
The added material parameters we made. We had named the scalar parameter "Glow Amount" |
Programming the Glow
Go back into the event graph. From the g pressed print string. create a dynamic material instance. Choose the one that says SM_teapot. This will create a pointer to the SM_teapot automatically.
 |
Create the node by dragging from the white output. Make sure to get the SM_teapot one because that is the object we want to glow |
 |
This will setup the node correctly with a pointer already for the target |
Change the source material to the material template you just made (M_MagicLamp_template). Now drag from the return value and create a Set Scalar Parameter value. This will not work correct if you don't drag from the return value. Change the parameter name to the parameter name you made for the material (we had named it Glow Amount) and change the value to something big to make it glow. Do the same for the g released key.
 |
The Timeline editor |
Note: for some reason when I tried to recreate this, it would not change from a linear line, so i made another keyframe, made it auto as well and adjusted it until it made a nice curved transition.  |
Finished node setups |
Make sure the Hot Amount output is connected to the value input of the Set Scalar Parameter Value. If you've set everything up correctly, we now have a smoother transition from not glowing to glowing and vice versa!