Reader small image

You're reading from  Blueprints Visual Scripting for Unreal Engine 5 - Third Edition

Product typeBook
Published inMay 2022
Reading LevelBeginner
PublisherPackt
ISBN-139781801811583
Edition3rd Edition
Languages
Tools
Right arrow
Authors (2):
Marcos Romero
Marcos Romero
author image
Marcos Romero

Marcos Romero is the author of the Romero Blueprints blog, which is one of the main references on the internet to learn about Blueprints. Epic Games invited Marcos to the Unreal Engine 4 closed beta program to experiment and collaborate with the evolution of the tools. He was also one of the first recipients of Unreal Dev Grants for Education. Marcos is a well-known figure in the Unreal community and, for Epic Games, he wrote the official Blueprints Compendium and Blueprints Instructor's Guide.
Read more about Marcos Romero

Brenden Sewell
Brenden Sewell
author image
Brenden Sewell

Brenden Sewell is a game designer and creative director with over a decade of experience leading teams in the development of compelling interactive experiences that entertain and inspire. Prior to joining Bossfight Entertainment to work on some upcoming secret projects, he explored the intersection of social impact and entertainment serving as the Creative Director for E-line Media. He has led developments from concept to live support on a variety of games ranging from a brain-training first-person shooter to a construction sandbox exploring the future of digital fabrication.
Read more about Brenden Sewell

View More author details
Right arrow

Chapter 18: Creating Blueprint Libraries and Components

In this chapter, you will learn how to create Blueprint Macro and Function libraries with common functionalities that can be used throughout a project. It will explain in more detail the concept of components. We will also learn how to create Actor Components with encapsulated behavior and Scene Components with location-based behaviors.

These are the topics covered in this chapter:

  • Blueprint Macro and Function libraries
  • Creating Actor Components
  • Creating Scene Components

By the end of this chapter, you will have created a Blueprint Function Library to simulate dice rolls, an Actor Component to manage experience points and leveling up, and a Scene Component that rotates around the Actor.

Blueprint Macro and Function libraries

Sometimes, in a project, you identify a macro or function that can be used in several Blueprints. The Unreal Editor allows you to create a Blueprint Macro Library to gather the macros that you want to share between all Blueprints. In the same way, you can create a Blueprint Function Library to share utility functions between all Blueprints.

The menu options to create Blueprint Function Library and Blueprint Macro Library are in the Blueprints submenu that appears when creating an asset:

Figure 18.1 – The menu options to create Blueprint Macro and Function Libraries

When creating a Blueprint Macro Library, you need to choose a Parent class. The macros of the library will have access to variables and functions of the Parent class selected, but the Macro Library can only be used by subclasses of the chosen Parent class. Selecting the Actor class will be the best option in most cases.

Let's create a Blueprint...

Creating Actor Components

When creating an Actor Blueprint, we often add components with encapsulated functionality ready to use, such as Projectile Movement, Static Mesh, and Collision components. We can also create our own Actor Components using Blueprints.

When creating a Blueprint, in the Pick Parent Class panel, there are two COMMON classes that can be used to create components, namely Actor Component and Scene Component:

Figure 18.19 – Creating Actor and Scene Components

The Scene Component is a Child class of the Actor Component that has the Transform structure (location, rotation, and scale). Because of the Transform, a Scene Component can be attached to another Scene Component. We will explore the Scene Component in the next section.

When scripting a component in the EventGraph, you can get a reference of the Actor that is using the component with the Get Owner node:

Figure 18.20 – Getting the reference of...

Creating Scene Components

We will create a Scene Component named BP_CircularMovComp that rotates around the Actor. Then, we will attach a Static Mesh Component to the BP_CircularMovComp component to simulate a rotating shield.

Follow these steps to create our Scene Component:

  1. Access the Chapter18 folder that we created in the first example of this chapter.
  2. Click the Add button in the content browser and choose the Blueprint Class option.
  3. On the next screen, choose Scene Component as the parent class. Name the Blueprint BP_CircularMovComp and double-click it to open the Blueprint Editor.
  4. In the My Blueprint panel, create the RotationPerSecond and DeltaAngle variables of the Float type:

Figure 18.39 – Creating the variables of the component

  1. Compile the Blueprint and select the RotationPerSecond variable. In the Details panel, set DEFAULT VALUE to 180.0. This value is in degrees, so the component will complete a rotation...

Summary

In this chapter, we learned how to create Blueprint Macro and Function Libraries to be used throughout the project. We created a Blueprint Function Library to simulate dice rolls.

This chapter explained the difference between Actor Components and Scene Components. We learned how to create an Actor Component to manage experience points and leveling up.

We also created a Scene Component that rotates around the Actor and attached a Static Mesh Component to it to simulate a rotating shield.

In the next chapter, we will learn how to use the Construction Script of a Blueprint to script procedural generation. We will also learn how to use the Spline tool and how to create an Editor Utility Blueprint.

Quiz

  1. The macros of a Blueprint Macro Library have access to variables and functions of the Parent class.

a. True

b. False

  1. A Blueprint Function Library can have functions and macros.

a. True

b. False

  1. An Actor Component is a Child class of a Scene Component.

a. True

b. False

  1. In an Actor Component, you can use the Get Owner node to get a reference of the Actor that is using the component.

a. True

b. False

  1. A Scene Component can be placed directly in a Level.

a. True

b. False

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Blueprints Visual Scripting for Unreal Engine 5 - Third Edition
Published in: May 2022Publisher: PacktISBN-13: 9781801811583
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (2)

author image
Marcos Romero

Marcos Romero is the author of the Romero Blueprints blog, which is one of the main references on the internet to learn about Blueprints. Epic Games invited Marcos to the Unreal Engine 4 closed beta program to experiment and collaborate with the evolution of the tools. He was also one of the first recipients of Unreal Dev Grants for Education. Marcos is a well-known figure in the Unreal community and, for Epic Games, he wrote the official Blueprints Compendium and Blueprints Instructor's Guide.
Read more about Marcos Romero

author image
Brenden Sewell

Brenden Sewell is a game designer and creative director with over a decade of experience leading teams in the development of compelling interactive experiences that entertain and inspire. Prior to joining Bossfight Entertainment to work on some upcoming secret projects, he explored the intersection of social impact and entertainment serving as the Creative Director for E-line Media. He has led developments from concept to live support on a variety of games ranging from a brain-training first-person shooter to a construction sandbox exploring the future of digital fabrication.
Read more about Brenden Sewell