A blueprint is a container for content as it can hold various components, scripts and data. It doesn't always need a script as it can be a data only blueprint. This means the designers can modify the data but not modify the behaviour of the blueprint.
Blueprints are a compiled object oriented visual scripting language and ties into the pre-exisiting UE4 framework class hierarchy. It is also completely embedded within UE4 and works by stringing together connections and nodes. You can also see the adjustments fairly quickly after the blueprint has been compiled.
There are two types of blueprints:
- Level blueprint which is one per level and only affects that level
- Class blueprint which can have multiple instances within a level and works in all levels
Blueprints are built on C++ and in fact when using blueprints you are using C++ as they can be even openned and edited in C++. This means both play nicely together.
Creating Blueprints
When creating a new blueprint, you can pick from a parent class which gives the new class some inherited functionality (hence why its object oriented). Most cases the parent class will be an actor, however, if there is a player controlled character or vehicle the parent class would be a pawn class.
Blueprints can be created from the content browser by clicking on the add new button or they can be created by placing various components within a scene, selecting said components, then converted to a blueprints class using the blueprint button in the upper middle section of the editor window.
The default scene root component is the base object which can affect its children components. This means if that root component moves, everything else moves with it. However, if you just move the child component, then the root component will stay still. You can also override the root component with another component by dragging the new root component on top of the default root component.
You can also add components or set meshes through the content browser by dragging it from the content browser to the blueprint window.
Blueprint Graphs
Construction script fire once at runtime and whenever a change is made in the editor. It can also be used for a variety of other features such as dynamically spawning in static meshes to randomly adjust how something might look. Such as a fence and the wooden planks that make up the fence, which could be spawning in different positions and rotations to create a variety of styled fences.
The event graph is the type of blueprint graph that will most likely to be used. In here we can program how the various objects work. So if we had a security camera we can use the Event Tick function (if this was Unity and C# this would be the Update function) to make the security camera move side to side, but then when the player moves within range it tracks the players movement and the security cameras light changes to red. To check if the player is within range we could use the Event Begin Overlap (if this was Unity, it would be the OnTriggerEnter function).
In the event graph we can create function graphs which can separate functionality and organise the event graph to be neater. This can be done by selecting a group of nodes, right clicking and selecting the collapse to function option. The advantage of creating a function is that it can be reused but also used and accessed within another blueprint.
You can also do the same but create macro graphs, which are similar to the functions graphs but don't require any input values. The macro graphs are more like utility functions and are accessible only in that blueprint unless a macro library is created and used. Like the function nodes, the macro nodes can be reused if needed.
You can also collapse nodes, which doesn't create a function graph or a macro graph but just helps tidy up the event graph and keeps things organise. It is important to note that these cannot be reused.
Types of blueprints
The level blueprint is used to create level specific functionality, this might be a useful for a shooting game where the player has x amount of time to escape the level before a bomb explodes as the levels before or after that one will most likely not require that functionality. The level blueprints also don't have access to the ability to add components or access the viewport like a class blueprint can.
Actor blueprints are modular blueprints that provide various functionality and can be reused throughout the level but also multiple levels. Unlike the level blueprint you can add various components to be used by the blueprint and access the viewport to move those components around if needed.
An animation blueprint is used to create the animation logic for various characters whether they are player controlled or not. A use for this is transitioning between idle, walking, jogging and running animations for the player based on the players movement speed. Unlike the actor blueprint, the animation blueprint also has another type of graph it can use. This graph is the anim graph, which can be used to set up state machines and animation transitions. The different between the anim graph and the event graph, is that the event graph controls the moment to moment variables whereas the anim graph controls the moment to moment final pose of the animation.
UMG (Unreal Motion Graphics) UI/ Widget graphs can be used to display and control a games user interface. An example of this is displaying the players health and energy bars, as well as updating them when the player takes damage or uses up stamina. It has an event graph which can provide the functionality of the UI elements. The designer tab is used to layout and add the various UI elements.
A child class inherits from a parent class, this allows us to use functionality from the parent class but also add some customisation based on the child class. An example of this would be item pickups. The parent class would have the functionality of what to do when the player hits the trigger volume but a child class would have extra functionality on top of that, so if it was a health pickup it would give the player more health where as an ammo pickup would give the player more ammo. To create a child blueprint, you go to the parent class you wish to use in the content browser and right click on it. At the top there should be an option to create a child class blueprint.
Blueprints Caveats
Blueprint Graphs
Construction script fire once at runtime and whenever a change is made in the editor. It can also be used for a variety of other features such as dynamically spawning in static meshes to randomly adjust how something might look. Such as a fence and the wooden planks that make up the fence, which could be spawning in different positions and rotations to create a variety of styled fences.
The event graph is the type of blueprint graph that will most likely to be used. In here we can program how the various objects work. So if we had a security camera we can use the Event Tick function (if this was Unity and C# this would be the Update function) to make the security camera move side to side, but then when the player moves within range it tracks the players movement and the security cameras light changes to red. To check if the player is within range we could use the Event Begin Overlap (if this was Unity, it would be the OnTriggerEnter function).
In the event graph we can create function graphs which can separate functionality and organise the event graph to be neater. This can be done by selecting a group of nodes, right clicking and selecting the collapse to function option. The advantage of creating a function is that it can be reused but also used and accessed within another blueprint.
You can also do the same but create macro graphs, which are similar to the functions graphs but don't require any input values. The macro graphs are more like utility functions and are accessible only in that blueprint unless a macro library is created and used. Like the function nodes, the macro nodes can be reused if needed.
You can also collapse nodes, which doesn't create a function graph or a macro graph but just helps tidy up the event graph and keeps things organise. It is important to note that these cannot be reused.
Types of blueprints
The level blueprint is used to create level specific functionality, this might be a useful for a shooting game where the player has x amount of time to escape the level before a bomb explodes as the levels before or after that one will most likely not require that functionality. The level blueprints also don't have access to the ability to add components or access the viewport like a class blueprint can.
Actor blueprints are modular blueprints that provide various functionality and can be reused throughout the level but also multiple levels. Unlike the level blueprint you can add various components to be used by the blueprint and access the viewport to move those components around if needed.
An animation blueprint is used to create the animation logic for various characters whether they are player controlled or not. A use for this is transitioning between idle, walking, jogging and running animations for the player based on the players movement speed. Unlike the actor blueprint, the animation blueprint also has another type of graph it can use. This graph is the anim graph, which can be used to set up state machines and animation transitions. The different between the anim graph and the event graph, is that the event graph controls the moment to moment variables whereas the anim graph controls the moment to moment final pose of the animation.
UMG (Unreal Motion Graphics) UI/ Widget graphs can be used to display and control a games user interface. An example of this is displaying the players health and energy bars, as well as updating them when the player takes damage or uses up stamina. It has an event graph which can provide the functionality of the UI elements. The designer tab is used to layout and add the various UI elements.
A child class inherits from a parent class, this allows us to use functionality from the parent class but also add some customisation based on the child class. An example of this would be item pickups. The parent class would have the functionality of what to do when the player hits the trigger volume but a child class would have extra functionality on top of that, so if it was a health pickup it would give the player more health where as an ammo pickup would give the player more ammo. To create a child blueprint, you go to the parent class you wish to use in the content browser and right click on it. At the top there should be an option to create a child class blueprint.
Blueprints Caveats
- There is a cost associated with using blueprints over native C++ code
- It is best to avoid doing complex maths or heavy operations every frame as blueprints use a virtual machine to translate the nodes into native C++ code
- Native C++ is always going to be as it doesn't require translation via virtual machine
- There is also some functionality that can only be performed using native C++ code and therefore that makes native C++ more powerful than blueprints
- Blueprints is event based and therefore require specific events to trigger the various functionality programmed in those blueprints
- Uses refererences and therefore possible to pass an invalid reference
- It is also possible to create circular dependancies, this is where two or more blueprints depend on each other and so when one blueprint is casted to another the new blueprints dependancies are loaded, which links back to the original blueprint, whose dependancies also start to load. This then kickstarts the new blueprints dependancies again and so on.
NB. You can use casting during collision checks to see if an object is a certain type, this is similar to Unity's tag system as then you can provide specific functionality if the cast succeeds or fails.
No comments:
Post a Comment