Appendix B
Blueprint Primer

Navigating, Creating and Connecting

RMB Click, hold and drag: Move the graph

Mouse Wheel: Zoom in / out

LMB Click on node: Select node

LMB Click, hold and drag in empty space: Marquee selection

LMB Click on selected node(s), hold and drag: Move Selected item(s)

RMB click in empty space: Open the -Graph Action Menu

LMB Click on node pin, hold and drag out to empty space: Open the Graph Action Menu

LMB click on node pin, hold and drag out to other pin: Make new connections Ctrl + LMB click on node pin with existing connection, hold and drag top new node pin: Move an existing connection.

Alt + LMB click on node pin to break connections.

Double-click on a wire to insert a reroute node (for keeping things tidy).

You can select multiple nodes and then right-click to choose Collapse Nodes. This will package the selection into a sublevel of the graph (useful for tidying sequences up). If you change your mind, you can right-click a collapsed node and choose Expand Node to unpackage it. To move into a collapsed node’s graph, double-click the node. Use the arrows in the top left of the graph to navigate back up to the main graph again.

Events and the Programming Paradigm

Blueprints are the implementation of a visual scripting system, and this follows normal programming methodology in terms of its sequential nature. You can only have one instance of an event in each Blueprint (i.e., only one <Event Begin Play>). You also can’t connect an exec output from one node to multiple nodes.

If you want to use an exec signal from either a node or an event in multiple places, you need to either connect them sequentially or make use of the <Sequence> node.

As an example, if you wanted a <Key Press> E to play a sound, turn a light off, and spawn an explosion, you could do it sequentially like this:

fig0655

Or by making use of the <Sequence> node, like this:

fig0656

Best practice is to avoid using the <Sequence> node whenever possible.

Compiling Blueprints

When you’ve created your Blueprint system, you need to compile (either using the button in the top left of the screen, or the F7 shortcut).

fig0657

Hopefully, it will compile fine and you‘ll get the green checkmark of success!

fig0658

However, sometimes there may be problems with your Blueprint, and it will not compile correctly, shown by a red sign.

fig0659

If this happens, you can use the compile results to identify and locate the problem.

fig0660

You can click on the linked object or connection (in the image above, the Target) to jump to the offending object and then resolve the issue (in this case, no valid reference provided to the Target input of a <Bind> node.

fig0661

Actor Blueprints

Actor Blueprints function in exactly the same way as the [Level Blueprint], but they also have Components that you can add to the Actor such as collision boxes, sounds, meshes, etc. Adding components is easy—simply use the +Add Component menu (in the ifig0006.jpg Viewport panel), then choose from the available types. Once added, you can set the component up in the ifig0006.jpg Details panel (i.e., add your Sound Cue, static mesh, etc.)

You can get references to any components within an Actor in the ifig0006.jpg Event Graph by simply dragging the reference variable into the ifig0006.jpg Event Graph, and you can then drag offthe reference to create function nodes and/or set variables within that component.

Below is an example of this using the Explosion_Core sound component within the [ExplosionMovingSound] (from the urban warfare level).

fig0662

Structures

Structure (or struct) variables contain a series of different variable types (a bit like an array, but with different variable types). These are useful ways of storing a variety of different information for reuse within your Blueprints. These can then be broken to enable you to get at the different variables contained within the struct.

An example of a struct variable is the Out Hit result obtained from a line trace (we used this when looking at footsteps and surfaces in Chapter 07).

fig0663

The Graph Action Menu

When you right-click in a Blueprint to create a new node, you are using the ifig0006.jpg Graph Action Menu. You can navigate through the different categories, or just search for nodes by name. If you have an Actor selected within the level and the Context Sensitive option ticked, you can search for functions and nodes that relate to that specific type of Actor.

fig0664

However, sometimes you may need to turn Context Sensitive offto find the node, function, or event that you are looking for. An example of this is the <Set Audio Listener Override>. With context sensitive enabled, you can’t see it.

fig0665

With context sensitive disabled, you can see it.

fig0666

Creating Nodes between Existing Connections

A useful little time saving device is that you can create nodes between existing connections simply by dragging offan output that already has a connection and creating a new node. The engine automatically creates the new node and makes the necessary connections to place it in-line.

fig0667

Finding Things in Blueprints

It’s likely that you’ll be producing some fairly complex Blueprint systems and so may struggle to remember where you put a specific node or variable. If this happens, you can use the Find feature within a Blueprint.

Use Ctrl + F to open the Find dialogue and type the name of the node you want to find.

fig0668

You can then double-click on the result and jump straight to it within the Blueprint.

Communicating between Blueprints

Casting

Casting is an extremely useful feature within the Blueprint system—it is where you take a reference to an object or Actor and then cast it to its parent class so that you can access variables within it (either get or set) and call functions and events within it.

A good example of this is the player character. In the [Level Blueprint] you might want to change a variable within the player character Blueprint in response to an in-game event, so you can create a reference to the player character using <Get Player Character> and then <Cast> this to its parent class (e.g., [MyCharacter]).

fig0669

You can then drag offthe AsMyCharacter output and call any events that have been set up in the Blueprint.

fig0670

You can also access any variables within that Blueprint as either a get or a set.

fig0671

Event Dispatcher

The Event Dispatcher system enables you to call functions and events with the [Level Blueprint] from an Actor Blueprint or other Blueprints (e.g., the HUD). An example of this would be to call an event within the [Level Blueprint] when the player character takes some damage.

First you need to create the Event Dispatcher within the Actor’s Blueprint (from the ifig0006.jpg MyBlueprint panel) and give it a name. Then within the ifig0006.jpg Event Graph, you <Call> the Event Dispatcher when the thing you want to trigger the dispatcher occurs (in this example, a Take Damage event).

fig0672

You then need to set up the receiver for this within your [Level Blueprint]. The best approach is to do this when the level starts (i.e., on begin play)—this way the receiver is always ready and waiting for the dispatcher to be called. Create a reference to your Actor, then <Cast> this to its parent class, and finally drag from this to <Bind> the receiver.

fig0673

Anytime the <Event Any Damage> is triggered within the player character Blueprint, the <Call TakeDamage_ED> Event Dispatcher will be called, and this will cause the <TakeDamage_ED_ Event_0> event to be triggered within the [Level Blueprint].

Getting References to Spawned Actors

So far we’ve looked at getting references to Actors that are placed within the level and so already exist (or the player character). But what if we want to get a reference to an Actor that doesn’t yet exist in the level and is spawned at some point as a result of an event occurring? All of the <Spawn> nodes provide a Return Value output that returns a reference to the Actor that was spawned. You can drag offthis and get access to any event, function, or variable that is contained within that Actor’s Blueprint.

fig0674

Below is an example of this using the [ExplosionMovingSound] Actor (from the urban warfare level) that demonstrates that we can access a variable contained within the Actor’s Blueprint and are able to <Set> it as the Actor is spawned.

fig0675

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

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