Swapping a Material

Once you have placed the Set Material node, notice that it is already connected via its input execution pin to the Event Hit node's output execution pin. This Blueprint now fires the Set Material Action whenever the Blueprint's Actor hits another Actor. However, we haven't yet set up the Material that will be called when the Set Material Action is called. Without setting the Material, the Action will fire but won't produce any observable effect on the Cylinder target.

To set the Material that will be called, click on the drop-down field labeled Select Asset underneath Material, which is inside the Set Material node. In the asset finder window that appears, type red in the search box to find the TargetRed Material we created earlier. Clicking on this asset attaches it to the Material field inside the Set Material node:

We have now done everything we need with this Blueprint in order to turn the target Cylinder red, but before the Blueprint can be saved, it must be compiled. Compiling is the process used to convert the developer-friendly Blueprint language into machine instructions that tell the computer what operations to perform. This is a hands-off process, so we don't need to concern ourselves with it, except to ensure that we always compile our Blueprint scripts after we assemble them. To do so, hit the Compile button in the top-left corner of the Editor toolbar, and then click on Save.

Now that we have set up a basic gameplay interaction, it is wise to test the game to ensure that everything is happening the way we want it to. Click on the Play button, and a game window will appear directly above the Blueprint Editor. Try both shooting and running into the CylinderTarget Actor you created:

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

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