A simple game with Blueprint

After you click on Stop, select the cubes and your actor. Then, hold Alt and create a copy of all by moving on the Y axis. Now, click on the second actor and pick the upper and lower cubes. Then, select one point light object from Modes | Basic on the left-hand side and place it close to the stage surface between the two cubes. Our goal is to turn on the light when the cubes experience collision and break one of the cube's physical constraints.

A simple game with Blueprint

Now, click on point light and navigate to Rendering in the Details section and uncheck Visible:

A simple game with Blueprint

Now, click on Blueprint and select Open Level Blueprint. Navigate back to editor and select your point light. Now, go back to the Blueprint editor, right click on it, and select Create a Reference to PointLight from the list. You will have a curvy box with the PointLight title on your blueprint stage. Now, locate the small blue hollow circle in the top-right corner of your point light box. Then, click and hold the mouse and move the pointer to the right. You will find a wire-like line that follows your mouse. When you leave the mouse, a list will appear with a search area to type. Enter toggle and click on Toggle Visibility (PointLightComponent) from the names in the list, as shown in the following screenshot:

A simple game with Blueprint

Now, navigate back to editor and select one of the lower cubes. Then, go back to Blueprint and use the same method to open the list, but this time, open Add Event for your cube name. Then, open Collision and select Add On Actor Hit. Now, connect a wire to the previous box you made, as shown in the following screenshot:

A simple game with Blueprint

What this does is you first define the reference to your PointLight and then add the Toggle functionality to the visibility of the light. However, you need to turn the light on by selecting Hit Event for your cubes. So, we can add Event for collision and set the event to execute our toggle function. Click on Play and check how it works. As you can see, PointLight turns on and off on each hit to the selected cube.

Now, we need to define another rule for our game. We need to disable the physical actor on the hit event. Then, select your actor over the other cube. Create a reference for it as you did for the lamp. Then, create the Break Constraint function with the break keyword on the search area. Now, select the cube that responds to the actor and then create another hit event and connect it to this function. This is how the result should look:

A simple game with Blueprint

Now, test the game. As a result of the heat effect, one cube turns the light on/off, whereas another falls on the game stage.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.146.237