Commentary Box

An overview of the Commentary Box Blueprint.

Choose your operating system:

Windows

macOS

Linux

BlueprintCommentary.png

This Blueprint creates a commentary hint box that opens up when the player comes within a certain radius. When viewed from a distance, the object appears as a floating puck that has an "i" in the middle of it. Once the player is within range, the puck flips upside down, forming an exclamation point "!" and the box of text expands out from it. This box constantly orients to point directly at the player.

These Blueprints use a Sphere Component to calculate a radius from the Actor. The commentary expands when the player enters that radius. The setup for the actual box portion is not terribly dissimilar to how one would draw a similar automated box on a web page, in which an artist creates the pieces of the box frame individually and then they are all stretched to surround the target area. For instance, to build the box, we start with two Static Meshes: a straight segment piece and a curved corner piece.

Segment.png

Corner.png

Segment Piece (Yes, it is just a square, really.)

Corner Piece

These pieces are then copied, stretched, and rotated to form a frame of the appropriate size. The script needs to simply figure out where the corners will be, and the scaling is done to coincide.

BoxDemo.png

It is important to note that automatic word wrap is not supported in this Blueprint. Instead, there is a string array variable named Lines that contains each line of text. The user needs to arrange the words on each line manually.

LinesProperty.png

If you open the graphs for this Blueprint, you may notice that it seems to be fairly math-heavy. At closer inspection, it is not really too complex , just keep in mind that a lot of math is needed to figure out exactly how to properly construct the text box from the provided Static Meshes.

Blueprint Setup

The Components List, Construction Script, and Event graph for this Blueprint perform the following tasks:

Blueprint Aspect

Purpose

Components List

The Components List for the Commentary Box is set up as follows:

CommentBox_CL.png

Construction Script

The Construction Script performs the following tasks:

  • Establish the size of the trigger Sphere Component.

  • Track the number of lines used, then get the length of the longest line.

  • Expand the Commentary Box if the user has enabled the Preview Mode variable.

  • Create the necessary TextRenderComponents.

  • Scale and reposition the box to account for the lines of text.

Event Graph

The Event Graph performs the following tasks:

  • At the beginning of play, set whether the particle system is working or not.

  • When the player enters the Sphere Component trigger volume, animate the box components so that they scale to the proper size, then create the text.

  • Every tick, rotate the Blueprint so that it faces the player.

Editable Variables

The commentary box has the following exposed properties:

BoxProperties.png

Property

Purpose

Border Width Padding

This adds some padding, allowing you to make the box wider if needed.

Preview Mode

When checked, the box will expand. Also, this will cause the box to begin play expanded.

Lines

Contains each of the lines of text that will be contained in the Commentary Box.

Trigger Scale

Allows for scaling of the Sphere Component trigger, in areas where you need to open the Commentary Box sooner.

Disable Particle Effect

Disables the ring-shaped pulse of particles that spawns from the center of the Commentary Box's puck.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss