The MeleeAction is used by item such as sword or body. It detects collisions and impact the targets.
One of the properties of the MeleeAction is to be able to create combos within a single component. This is done by having multiple AnimatorAudioStates within the Trigger. In addition a use can trigger multiple attacks each with their own ID (for example a special attack that swings the sword rapidly hitting multiple times).
The Module groups for the MeleeActions are
- Trigger [S]: Simple combo or repeat combo are usually used.
- Usable [M]: For any module shared between an UsableItemAction.
- Attacker [S]: The main melee module will control how the attack takes place.
- Collision [S]: Detects targets to be impacted.
- Attack Effects [M]: The effects to trigger when attacking.
- Impact [M]: Invoke function on impact using the ImpactData.
- Recoil [S]: Recoil when hitting a hard surface causing the attack to stop.
- Extra [M]: Any other modules that are specific to melee but does not fit in any other group.
Groups noted as ‘[M]’ can have many modules active at once. Usually all the enabled modules are considered active.
The Attacker module is the main module controlling how many attacks to do. Each Attack comes with a MeleeAttackData containing the properties
- Attack ID: Differentiates the attack from one another to allow different effects and/or impacts.
- State Name: Have a state activate while that attack is active allowing great flexibility not only on the item but on abilities too.
- Strength Multiplier: Instead of having a different Impact for each swing sometimes it is easier to simply set a multiplier.
- Single Hit: Should the Attack hit once? The collision will choose what it does with this value.
A basic module that does a single Attack and use AnimationSlotEventTrigger for start complete and chain.
A module that does a multiple attacks and use AnimationSlotEventTrigger for start complete and chain for each of them. A MeleeAttackData can be assigned for each to allow different effects and/or impact.
When an Attack starts the Collision will start checking for hits, whether it is using physics cast or hitboxes.
Use colliders to create hitboxes for the attack to detect collisions. The module will physics overlap using the collider shape to detect collision. Only BoxCollider, SphereCollider and CapsuleCollider are supported.
Lerped Hitbox Collision
There are times where the hitbox moves so quickly between frames that it can miss small objects. The lerped Hitbox will detect collisions by lerping between the previous frame and new frame position. The density of the lerp can be set.
Sphere Overlap Collision
Use a SphereCast in front of the character to detect collision. An offset an radius can be used for control.
The effects to invoke when the attack starts, complete or on update while the attack is active.
Generic Item Effects
Uses a ItemEffectGroup on start or complete. The effect can be made to be invoked only for certain Substate Index values or Attack IDs.
Enabled Disable Effect
Enable or Disable a GameObject while the attack is taking place. The effect can be made to be invoked only for certain Substate Index values or Attack IDs.
The impact to invoke when the attack collides with a target.
Generic Melee Impact Module
Uses a ImpactActionGroup. The impact can be made to be invoked only for certain Substate Index values or Attack IDs.
On Impact the surface impacted can be defined as solid which can potentially cause a recoil.
If a solid object ShieldCollider or RecoilObject is detected as the impacted object, an additive SubstateIndex is set. This allows the animation to change.
Extra modules that do not fit in any other group.
Enable and or spawn a trail that can be set to be always active or only active while attacking.