STEP by STEP MAKE AN INTERACTIVE LAMP
01 THE CREATE LAMP AND BLUEPRINT
first thing we have to do is import the model of the lamp that we want to make interactive. For this exercise we are going to use a floor lamp – name it SM_INT_LAMP. Once we have it in Unreal in the same folder as the Content Browser, right-click and select Blueprint Class and then select Actor. Once it’s done we will have our new blueprint ready to be tweaked and for us to give it the right actions. Name it BP_LAMP. It is really important to name each element properly so that we can find it later in the World Outliner or the Content Browser.
02 CREATE BASE MESH AND ELEMENTS
Open the blueprint and click Add Component. Add Static Mesh, select it and in the right window select the imported lamp model, in this case SM_INT_LAMP. Now select Add Component, choose a Spot Light and move it to the appropriate position. Once it’s done, in the Eventgraph we have to add an Enable Input. Next add a Get Player Controller so we can give the input, then add Input X so we can add the input in our keyboard when pressing X. Finally select the Spot Light, right-click in the grid and select Call Function>rendering>toggle Visibility. Compile and then test it.
03 full interaction
Now in Add Component add a Box Collision and name it COLLIDER. Once selected move in so it can be around the static mesh. Now in the Eventgraph we will add a control that triggers the interaction once we are close to the lamp, so erase Event Begin Play and right-click over COLLIDER, add event and select On component begin overlap so the input can be activated once we are close. Repeat this, but this time select Component connected to a Disable Input and this one to the get player controller so once we are away the input can be turned off. Compile and test.
04 finishing details
It would be useful to know when to press X to turn it on and turn it off, so in the viewport add a Textrender and, the same as before, move it to the lamp and change its position so it can be in the preferred place. Now in the Eventgraph select the Textrender, rightclick in the grid and select Call Function> rendering> toggle Visibility. Connect Enable Input and Disable Input to it, and this way the text will only appear once we are near the Collision we created before. Finally select the Textrender, and in the right menu in Rendering uncheck Visible. Compile and Save..
adding interaction to our Unreal Engine levels gives our users a more immersive experience.