I created a multi-hit processing script.
When the attack judgment is active, setting ActivatedSkillId in VariableSettings allows the script to automatically perform hit judgments for the corresponding skill based on the skill data configured in the database, executing independent hit control for each enemy.
Judgments are performed every HitInterval (frames), with a maximum of HitCount hits.
If HitJudgeMode is set to 0 in the database, a hit judgment occurs every time contact is made with the target. If set to 1, the judgment continues as long as contact is maintained.
Once a hit judgment occurs, signals can be emitted and other actions can be taken, so feel free to write your own custom logic!
As a piece of trivia, signals sent via the script in VS (Visual Studio) require the data type of the sent value to match the receiver’s expected type for the signal to trigger.
Hit judgments can be reset using reset_ methods.
HitCounter.gd (4.5 KB)
SkillList.csv (967 bytes)
This script is designed to be attached to an AttackArea2D node to emit a signal upon contact with a target.
Even if contact occurs multiple times, the processing is handled based on the hit count and cooldown (interval) for each skill.
[Setup Instructions]
① Node Structure
Assume a Player character with the following node structure as an example:
Player (CharacterBody2D)
├── AttackArea2D ← Attach this script to this node
② Script Attachment
Attach the following script (the one just completed) to the AttackArea2D node:
extends Area2D
# (Omitted: Attach the full script from above)
③ Inspector Settings
Configure the AttackArea2D node in the Inspector as follows:
target_group→"Enemy"(The group name of the contact target)variable_settings→ Reference../VariableSettings
④ Setup for Contact Target
Prepare a signal on the enemy character side (e.g., Enemy).
[Operation Flow]
AttackArea2Dcomes into contact with a node in theEnemygroup.- Retrieve the current skill ID from
VariableSettings(You must set the skill ID toActivatedSkillIdduring the attack). - Read the
HitCountandHitIntervalconfigured for the skill viaGameManager.get_project_database_plain(...). - Determine whether a hit judgment is permissible based on the history recorded in
hit_registry. - If valid:
- Increment the hit count.
- Emit the
attackedsignal of the target node usingemit_signal().