InteractTrigger / InteractTriggerX
InteractTrigger is a base class that defines various interaction behaviors for weapons. InteractTriggerX extends this base class by adding scripting capabilities.
#
OverviewIn 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 ParametersWe 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 immediatelyskillChargeEndTime
: Duration needed to fully charge the skillactivateTime
: Duration of the skill effect
#
Implementation DetailsThe 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 HierarchyInteractTrigger
: Base class providing core interaction functionalityInteractTriggerX
: 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 | |||||
Example | continuous update skills: telekinesis, sprint spear, slash katana | one-shot skills: gun firing | shoot and charge skills: storm pistol | charge-to-state skills: thunder spear | charge-and-release skills: fireball spell |
Actual Mana Calculation | manaCostOnCharge | manaCost | manaCost manaCostOnCharge | manaCostOnCharge | manaCostOnCharge |
Callbacks | OpenSkill UpdateSkill CloseSkill | UpdateSkill | UpdateSkill OnChargeBegin OnChargeReady OnChargeUpdate OnChargeRelease OnChargeCancel | OnActivateBegin OnActivateEnd OnActivateCancel | OnChargeBegin->OnChargeReady->OnChargeUpdate->OnChargeRelease |