-
-
Notifications
You must be signed in to change notification settings - Fork 8
Home
The heart of the plugin is the UMeleeTraceComponent
actor component. This component should be attached to an actor that will be the owner of the traces. In most cases this will be a character.
Example character actor's hierarchy:
The component itself has only one property which is the trace channel used for tracing hits. Please note that the default value for this property is assigned from Project Settings but be overriden per component here.
Start Trace
- call this to manually start tracing. This function call takes 1 parameter which is Melee Trace Info
structure. This structure is described with more details in the next paragraph below. The function returns Melee Trace Instance Handle
.
User is responsible for storing this handle and use it whenever calling an End Trace
function.
End Trace
- call this to manually stop tracing. This function call takes 1 parameter which is Melee Trace Instance Handle
.
Start Trace With Context
- this is an alternative to Start Trace
function for cases where user cannot store any state thus cannot store trace instance handle. Example of such user is anim notify state which cannnot store any state, so instead the object is used to generate unique hash that is associated with the trace. It has a limitation that it cannot start more than one trace for the same context object and so is not a recommended way.
End Trace With Context
- matching function to Start Trace With Context
. Please note that context object must be exactly the same object that was used for the corresponding start trace function.
Force End All Traces
- forcefully ends all traces for this component. Useful for cases when a character dies for example.
Is Any Trace Active
- returns bool whether this component is executing any trace at the moment or not.
Set Trace Channel
- manually overrides trace channel in runtime.
Get Trace Channel
- returns trace channel currently set for this component.
Get Actors Hit By Trace
- returns an array of unique actors that have been hit by the trace specified by the trace instance handle.
Get Actors Hit By Trace With Context
- same as Get Actors Hit By Trace
but with context object instead trace instance handle.
Invalidate Melee Trace Handle
- invalidates trace handle
Is Melee Trace Handle Valid
- checks if a trace handle is valid
Melee Trace Info
- this is a structure that defines all the properties for a trace. Trace Shape
property is an instance of an object that can be one of the shapes described in the Trace Shapes paragraph.
Please note that the socket start and socket end are socket names of any mesh component attached to the actor that is the owner of the Melee Trace Component
. It will also work if you attach child actors to your owner and have mesh component inside that child actor.
Make Line Shape
Make Sphere Shape
Make Capsule Shape
Make Box Shape
There are three delegates that are broadcasted from the Melee Trace Component
.
On Trace Start
is broadcasted whenever a new trace is started. Please note that single animation can have more than one trace (more than one anim notify states).
On Trace End
is broadcasted whenever a trace ends. Please note that this doesn't mean attack animation is finished. There might be more traces defined further down the animation itself.
On Trace Hit
is broadcasted whenever a trace hits a target. This is the best place if you would like to spawn hit effects and apply damage to hit target. Please note that single trace can hit an arbitrary actor ONCE. Each consecutive hit is ignored for this trace.
Wait for Melee Trace Event Hit
- a latent node that tightly packs all three melee trace component's delegates, however it doesn't expose data that is normally broadcasted together with On Trace Start
and On Trace End
delegates.
Anim notify state is a very convenient way to define the data for the trace as well as perfectly time it's start and end. To add anim notify state to your animation right click on the notify track, choose anim notify state and find Melee Trace
. Then adjust start and end position as you wish.
Example start:
Example end:
Then inside the anim notify state properties fill in the data inside Melee Trace Info
structure same way as in case for Start Trace
function described earlier.
Example trace data configuration:
By default, melee traces are using WorldStatic
collision channel. This can be changed globally in the Project Settings
inside Game -> Melee Trace Settings
.
This is the case that was presented in the gallery videos and in the section above. You define start and end socket of a weapon and use single anim notify state to define beginning and the end of the trace.
This is the case where a character holds one sword in each hand. Due to the fact that the system is scanning for a first matching skeletal mesh where defined sockets exist it is important for both swords skeletal meshes to have unique set of sockets. This way we can identify left hand sword by it having sockets named TraceStart_LeftSword
and TraceEnd_LeftSword
, and the right hand sword by it having sockets named TraceStart_RightSword
and TraceEnd_RightSword
.
With the above set you can simply define two anim notify states in parallel in separate notify tracks and it will work as expected.
This kind of attack is special because it's basically an instant attack that doesn't really have duration but it also has the same beginning and the end (in most cases). Luckily the system will handle this case just fine.
Add Melee Trace anim notify state to the animation and make it just one frame long. In the properties of the state define Start Socket Name
and End Socket Name
to the same value. Reduce Trace Density
to 1. Inrease Radius
to match the stomp/explosion radius. That's it, the attack is ready to go.
User can access some debug properties inside Editor Preferences as seen in the screenshot below.
User can change debug drawing color in plugin's project settings as seen in the screenshot below:
User can toggle debug drawing for traces during animation preview in the animation editor without entering the game. Note that this option is disabled by default and need to be toggled in the anim notify properties.
Debug properties exposed in the editor preferences are the same values that can be accessed via console command. To enter console command press ~
key and type one of the below:
MeleeTrace.ShouldDrawDebug <value>
- default value set to 0. Change to 1
or true
to see debug drawings of the traces.
MeleeTrace.DrawDebugDuration <duration>
- default value set to 1.0. Change to arbitrary positive value to make debug drawings visible for a shorter or longer period of time.