Skip to content
Robert Lewicki edited this page Mar 29, 2024 · 17 revisions

Quick Start

Melee Trace Component

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:

image

Properties

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.

image

API

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.

image

End Trace - call this to manually stop tracing. This function call takes 1 parameter which is Melee Trace Instance Handle.

image

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.

image

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.

image

Force End All Traces - forcefully ends all traces for this component. Useful for cases when a character dies for example.

image

Is Any Trace Active - returns bool whether this component is executing any trace at the moment or not.

image

Set Trace Channel - manually overrides trace channel in runtime.

image

Get Trace Channel - returns trace channel currently set for this component.

image

Get Actors Hit By Trace - returns an array of unique actors that have been hit by the trace specified by the trace instance handle.

image

Get Actors Hit By Trace With Context - same as Get Actors Hit By Trace but with context object instead trace instance handle.

image

Invalidate Melee Trace Handle - invalidates trace handle

image

Is Melee Trace Handle Valid - checks if a trace handle is valid

image

Structures

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.

image

Trace Shapes

Make Line Shape

image

image

Make Sphere Shape

image

image

Make Capsule Shape

image

image

Make Box Shape

image

image

Events

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).

image

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.

image

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.

image

Async nodes

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.

image

Anim Notify State

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:

image

Example end:

image

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:

image

Project Settings

By default, melee traces are using WorldStatic collision channel. This can be changed globally in the Project Settings inside Game -> Melee Trace Settings.

image

Use cases

Slash attack

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.

Double sword attack

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.

image

Stomp attack

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.

image

image

Debugging

Editor developer settings

User can access some debug properties inside Editor Preferences as seen in the screenshot below.

image

Debug draw colors

User can change debug drawing color in plugin's project settings as seen in the screenshot below:

318046578-1a9d4924-0ef4-49a4-a4d1-6fd27594cc19

Trace preview in animation editor

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.

318046075-c587a8be-62ec-40dd-b315-34c35ddb0402

CVars

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.