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 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.
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.
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: |
Construction Script | The Construction Script performs the following tasks:
|
Event Graph | The Event Graph performs the following tasks:
|
Editable Variables
The commentary box has the following exposed properties:
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. |