Closed mustachebutter closed 2 months ago
When the bug happened, this is being called repeatedly. So start debugging from here BaseCharacter.cs#68
if(IsDead && !_hasTriggeredOnDead)
{
GD.Print("In IS DEAD and should only be triggered once!");
OnCharacterDeadEvent?.Invoke();
_hasTriggeredOnDead = true;
}
So currently, it triggers more often when switching to another weapon (from Fireball to Zap). The theory is that, when Zap dealing damage, it could have lowered it enough for any Burn stacks left ticking and killing it (triggering the OnTargetDied
). However, when trying to set the burn explosion's position to the target position. The Target
is null and caused NullReferenceException, which shouldn't be possible since it would be QueueFree() after the fact.
Further thoughts lead me to thinking:
OnTargetDied
(because Burn was still active on the target). When the explosion is trying to happen the Target became null?# Logs
Dead event: False
Removed enemy: True, Enemy
Dead event - 2: True
Dead event: False
Removed enemy: True, @CharacterBody2D@2
Dead event - 2: True
Dead event: False
Removed enemy: True, @CharacterBody2D@4
Dead event - 2: True
Dead event: False
Removed enemy: True, @CharacterBody2D@3
Dead event: False
Dead event: False
Dead event: False
The error occurred because the status effect when expired only got removed from the list of status effect on the character rather than being unsubscribed to events that it had. When other types of weapons/damages dealt damage to the character. This will trigger OnCharacterDeadEvent
-> also calling the OnTargetDied
handler method in Burn because it is not being unsubscribed. So the godot editor was throwing NullException, causing the code that destroy the projectile freeze at the time
Describe the bug Projectiles work fine for the first couple of shots. But the more it tries to hit the target consecutively, something didn't trigger and makes the projectile indestructible. Meaning the projectile will stuck colliding with the character while not applying any effects.
Expected behavior Should Dequeue itself properly.
Screenshots If applicable, add screenshots to help explain your problem.
https://github.com/mustachebutter/GodotAutoSurvival/assets/43947255/d4be7ec6-6067-48b8-9813-c8f5289d2f04