Greetings again,
In my game, I have a complex system for enemy immunity frames to make it work similarly to Terraria’s local immunity system:
Here’s how it works:
- Each attack (HarmfulThings group in this case) is given a UID when it’s created, and each enemy has a structure variable that keeps track of the UID of the attack that hit them
- If the bullet collides with an enemy, check this:
- If the UID of the attack that hit them does not exist in their structure
OR - If the UID DOES exist in the structure, AND if the Time from start is greater than the HarmfulThing’s UID that exists in the structure + 0.2
(0.2 is the time the enemy is immune)
- Add the UID of the attack to the enemy’s structure, and deal damage
With this system, it makes sure the attack can only hurt an enemy every 0.2 seconds, and multiple attacks can hit an enemy, even if they are immune to the one that just hit them
Simply, the enemy becomes immune to that one instance of the attack for a brief time
It works very well for bullets and things. However, I have another object that exists in the HarmfulThings group. The player’s own attack
When I hit an enemy, there’s a very small random chance for the attack to hit the enemy twice:
This ONLY applies to the player’s attack. Nothing else in the group
Is there a way to patch this bug out? I’ve tried different things, but nothing seems to work
Does anybody have any ideas on what I can do to fix this? It’s driving me crazy