In this article, I would like to present about the implementation of Particle effects, Trace effect and Options Widget which I did as part of my Graphics for Games final project using Unreal Engine 4. The main idea of the project is to design a level of game play with an third person actor holding a light Saber in his hand, capable of various attack postures and providing proper Trace, Particle effects when the saber hits an object in the map along with Settings/Options widget.
Introduction
It is recommended to do the implementation with C++ code. However, there are situations when it is very useful to create your level Blueprints for the implementation. Such situations might occur when there are specific conditions or needs for a new game play feature or a part of the simulated game world. This is the situation which we came across when developing our project. So we proceeded implementing the project using Level blueprints.
Implementation
Implementation
The first step to start out with my part of the project is to find the specific location where the saber is hitting the objects and to leave a TRACE in there, Which in fact replicating that collided old mesh with a new dynamic mesh. At this point I came across Raycasts (Tracing) in Blueprints from the blueprint function library.
Each Shape Trace functions like a Line Trace where you are sweeping and checking for collision from a start point to an end point, however the Shape Traces have an added layer of checking as you are using a shape as a volume of sorts in your Raycast.
SphereTraceByChannel
Sweeps a sphere along the given line and returns the first blocking hit encountered. This trace finds the objects that RESPONDS to the given TraceChannel
Target is Kismet System Library
Inputs
| In
Exec
| ||
| Start
Vector
|
Start of line segment.
| |
| End
Vector
|
End of line segment.
| |
| Radius
Float
|
Radius of the sphere to sweep
| |
| Trace Channel
ETraceTypeQuery Enum
| ||
| Trace Complex
Boolean
|
True to test against complex collision, false to test against simplified collision.
| |
| Out
Exec
| ||
| Out Hit
Hit Result Structure
|
Properties of the trace hit.
| |
| Return Value
Boolean
|
True if there was a hit, false otherwise.
|
Here, given the saber mesh socket locations as the input and was able to store the collided locations in an structure array. Below is the blueprint implementation for Trace hit lookup.
Now the task is to leave the trace on the object when hit by the saber with the stored locations as input from the struct array using decals.
Decals
Decals are Materials that are projected onto meshes in your level, including Static Meshes and Skeletal Meshes. These meshes can have a Mobility setting of Static or Movable and the Decal will still project on them. Many Decals can be rendered at once without a large performance decrease.
Spawn Decal Attached
Spawns a decal attached to and following the specified component. Does not replicate.
Target is Game play Statics
Inputs
| In
Exec
| ||
| Decal Material
Material Interface Object Reference
|
decal's material
| |
| Decal Size
Vector
|
size of decal
| |
| Attach to Component
Scene Component Object Reference
| ||
| Attach Point Name
Name
|
Optional named point within the AttachComponent to spawn the emitter at
| |
| Location
Vector
|
Depending on the value of Location Type this is either a relative offset from the attach component/point or an absolute world position that will be translated to a relative offset
| |
| Rotation
Rotator
|
Depending on the value of LocationType this is either a relative offset from the attach component/point or an absolute world rotation that will be translated to a realative offset
| |
| Location Type
EAttachLocation Enum
|
Specifies whether Location is a relative offset or an absolute world position
| |
| Life Span
Float
|
destroy decal component after time runs out (0 = infinite)
|
| Out
Exec
| ||
| Return Value
Decal Component Object Reference
|
The same structure array with stored burn locations is also used for spawning an emitter at that instance which will provide the particle effects in the scene by loading a emitter template to the emitter.
Unreal Engine contains an extremely powerful and robust particle system, allowing artists to create mind-blowing visual effects ranging from smoke, sparks, and fire to far more intricate and otherworldly examples. Unreal's Particle Systems are edited via Cascade, a fully integrated and modular particle effects editor. Cascade offers real-time feedback and modular effects editing, allowing fast and easy creation of even the most complex effects.Particle systems are also very closely related to the various materials and textures applied to each particle. The primary job of the particle system itself is to control the behavior of the particles, while the specific look and feel of the particle system as a whole is often controlled by way of materials.
Unreal Engine contains an extremely powerful and robust particle system, allowing artists to create mind-blowing visual effects ranging from smoke, sparks, and fire to far more intricate and otherworldly examples. Unreal's Particle Systems are edited via Cascade, a fully integrated and modular particle effects editor. Cascade offers real-time feedback and modular effects editing, allowing fast and easy creation of even the most complex effects.Particle systems are also very closely related to the various materials and textures applied to each particle. The primary job of the particle system itself is to control the behavior of the particles, while the specific look and feel of the particle system as a whole is often controlled by way of materials.
Spawn Emitter at Location
Plays the specified effect at the given location and rotation, fire and forget. The system will go away when the effect is complete. Does not replicate. Target is Game play Statics.
Options Widget, Unreal Motion Graphics UI Designer (UMG) is a visual UI authoring tool which can be used to create UI elements such as in-game HUDs, menus or other interface related graphics you wish to present to your users. At the core of UMG are Widgets, which are a series of pre-made functions that can be used to construct your interface (things like buttons, checkboxes, sliders, progress bars, etc.). These Widgets are edited in a specialized Widget Blueprint, which uses two tabs for construction: the Designer tab allows for the visual layout of the interface and basic functions while the Graph tab provides the functionality behind the Widgets used.
In order to start working with Unreal Motion Graphics, you will first need to create a Widget Blueprint. By default, the Widget Blueprint Editor opens up on the Designer tab when a Widget Blueprint is opened. The Designer tab is the visual representation of the layout and will give you an idea of how the screen will appear in-game. By using the buttons, check boxes and slider I'm able to design the below widget.
Using the graph tab of widget blueprint editor, Here that you will create the networks of nodes and wires that will define your scripted behavior. Added few on Click Events and on Slide events to the graph and defining them according to the setting feature. I used console command blueprint function to show the effects during game play. Below are the sample blueprints for event graph functions.
Once you have created and laid out your Widget Blueprint, in order for it to be displayed in-game, you will need call it by using the Create Widget and Add to Viewport nodes inside another Blueprint.
Here is a small snippet showing the functionalities implemented in the project
Challenges
Initially started up the project by implementing it via plugins instead of utilizing level blueprints. I was able to develop a plugin and link it to the project with few basic functions, while coming to some complex functions I faced issues in implementing them. Apart from this I thought of implementing few collectibles and jump pad objects in the level of game play with sound components to them, Such that actor will perform actions accordingly when he encounters them, But I faced difficulties in adding the trigger box as Actor begin Overlap with character actor.
References
"UMG UI Designer"
"Widget Blueprints"
"Cascade Particle Systems"
"Particle System Level of Detail (LOD)"
"Emitter Location"
"Widgets"