Skip to main content

InteractTrigger / InteractTriggerX

InteractTrigger is a base class that defines various interaction behaviors for weapons. InteractTriggerX extends this base class by adding scripting capabilities.

Overview#

In the game, weapon interactions are implemented as a skill system. Each interaction type is treated as an independent skill, including but not limited to:

  • Special attack modes
  • Shooting mechanics

Basic Skill Parameters#

We provide several basic skill parameters that can be combined to create common interaction patterns. Each skill has the following key timing parameters:

  • instantSkill: Whether the skill activates immediately
  • skillChargeEndTime: Duration needed to fully charge the skill
  • activateTime: Duration of the skill effect

Implementation Details#

The actual implementation of these interactions is handled through LuaScript used by the InteractTriggerX component. Different parameter combinations will trigger different callback functions within the script:

Class Hierarchy#

  • InteractTrigger: Base class providing core interaction functionality
  • InteractTriggerX: Extended class that adds scripting support through LuaScript

Important Note: Since InteractTrigger and InteractTriggerX have an inheritance relationship, do not add both components to the same object to prevent unexpected behavior in Lua scripts.

The following table illustrates how different parameter combinations affect the mana cost system and which callback functions will be triggered:

Parameters Selection
instantSkillโˆšโˆš
skillChargeEndTimeโˆšโˆšโˆš
activateTimeโˆš
Combination Effect
Examplecontinuous update skills: telekinesis, sprint spear, slash katanaone-shot skills: gun firingshoot and charge skills: storm pistolcharge-to-state skills: thunder spearcharge-and-release skills: fireball spell
Actual Mana CalculationmanaCostOnChargemanaCostmanaCost manaCostOnChargemanaCostOnChargemanaCostOnCharge
CallbacksOpenSkill UpdateSkill CloseSkillUpdateSkillUpdateSkill OnChargeBegin OnChargeReady OnChargeUpdate OnChargeRelease OnChargeCancelOnActivateBegin OnActivateEnd OnActivateCancelOnChargeBegin->OnChargeReady->OnChargeUpdate->OnChargeRelease