Oregon State University|blogs.oregonstate.edu

Object Oriented Blueprinting

  February 8th, 2024

My group’s “Escape Room Challenge” has provided us an awesome opportunity to showcase some introductory capabilities of the Unreal Game Engine in a fun and interactive way.

(Image source: https://www.unrealengine.com/en-US/)

One of my favorite features of Unreal is the built-in “Blueprint” visual coding language.  While I enjoy writing code, I appreciate that Blueprint allows users that are both new to coding and seasoned professionals to jump into the development process within Unreal. 

(Image source: https://docs.unrealengine.com/5.2/en-US/blueprints-visual-scripting-in-unreal-engine/

Let’s take a look at a piece of sample code from the content pack we used as the base for our project: Modular Victorian House.  A pack that I was lucky enough to get for free during the Epic Games monthly sale. 

(Image source: https://www.unrealengine.com/marketplace/en-US/product/victorian-house

In the pack, among the provided content, is the “Blueprint” code for an interactive door.   Included functionality allows the door to be opened or closed (top) as well as to to alter the cursor to indicate the door can be opened (bottom).  

(Image source: Unreal Editor screenshot of content from https://www.unrealengine.com/marketplace/en-US/product/victorian-house

For this example, we will focus on just the top section → the “Open Door” code segment. 

(Image source: Unreal Editor screenshot of content from https://www.unrealengine.com/marketplace/en-US/product/victorian-house

First, on the left in red we see TWO separate event triggers: “Event On Interact” and “Event ActorBeginOverlap”. We look at the “Event On Interact” trigger that performs the open and close functionality.  From the trigger, it splits into a option for based on the door’s current status: closed (A) or open (B).  While it next feeds into a sequencing function that also triggers the sound effect, we are solely going to focus on the portion that feeds into the function “Door”.

(Image source: Unreal Editor Screenshot of content from https://www.unrealengine.com/marketplace/en-US/product/victorian-house

Look familiar? This event trigger resembles the Scratch block coding language that is intended to be a gateway to coding.  In the snipped below, we create an event that broadcasts a message called “open_door” that the door object would be listening to.  Once that code segment hears the message, it will then trigger the code segment that opens the door (not pictured).

(Image Source: https://scratch.mit.edu/projects/editor/?tutorial=home)

Back in Blueprint, once the “Door” function receives the cue “Play” (for opening the door) or “Reverse” (for closing the door), it completes two tasks: 1) it edits the “Yaw” of the door via the “Make Rotator” function, in order to rotate its physical look within the simulated space, and 2) it updates the “Relative Rotation” of the simulated door object by specifically referencing the “Mesh Door 02” object as the “Target” and the updated rotation from the “Make Rotator” function, to supply its final rotation.  

(Image source: Unreal Editor screenshot of content from https://www.unrealengine.com/marketplace/en-US/product/victorian-house

With the Blueprint code above in mind, what might this functionality look like in Python instead? Below I have coded up a VERY BASIC (essentially pseudocode) version of the functionality to see how it might compare. We see that it essentially works off the same principles: 1) it waits for a trigger, 2) it calls a function to check the current status of the door, and 3) it updates the rotation of the object to reflect the desired rotational status.

With these similarities in mind, I choose to think of Blueprint as somewhat of a blend of Scratch (block-style) coding, and more formal Object Oriented coding languages like Python or C++.  As it provides deep functionality for creating games (from the OOP languages) but also maintains the ease of use for the user – especially new users (similar to Scratch). 

Upon starting with Blueprint, I found the learning curve was a bit steep. After spending some time working with this visual coding language, I find myself better understanding the connections and workflow.

On first look at the functionality for a door alone, it is very intimidating. All the boxes and white lines connecting different things makes it confusing. While I cannot completely fault the language for this, I will say that sometimes the links (white lines) that connect the functions can make it hard to follow. Perhaps it would be improved by color-coding these links based on the data type being transmitted via these links.

(Image source: Unreal Editor screenshot of content from https://www.unrealengine.com/marketplace/en-US/product/victorian-house)

Despite the learning curve of the language, I find that the overall benefits and friendliness of the language outweigh the downsides. The content packs available in the marketplace (many for free) provide example functionality for many Blueprint functions and the seemingly endless wealth of online tutorials, forms, and courses, make this an amazing tool.

(Image source: Epic Games in-app Marketplace screenshot from https://marketplace-website-node-launcher-prod.ol.epicgames.com/ue/marketplace/en-US/assets?count=20&sortBy=effectiveDate&sortDir=DESC&start=0&tag=4910)

Unreal Engine’s Blueprint coding language is a great opportunity to utilize extensive capabilities in game development while still trying to understand the depth of coding applications, truly making it the “best of both worlds” (Hannah Montana would be so proud). 

Peace out coders!

-Kristy

Print Friendly, PDF & Email

Leave a Reply