In my game, if the Enemy’s (Health - DamageAmount <= 0), then it plays a death animation. At the end of the death animation, there is a Notify, which I am using in the EventGraph to call a function in C++ called DeathEnd, which pauses the Anims. Everything works perfectly without the timer, which waits three seconds then calls Disappear(), which only Destroy() the actor.
However, if I add the timer to the DeathEnd() function, the game crashes as soon as (Health-DamageAmount<=0), never calling Die() or displaying the UE_LOG I put there (which says “pre-die”).
I have the delay time, called “DeathDelay” initialized in the constructor, and all the parameters necessary are set in the enemy/character/weapon blueprints (sometimes they get reset to null, so I’m making sure they’re all set each time I play test).
I’m getting better all the time at de-bugging my own stuff, but this one really has me stumped. If you need any more information or screenshots, please let me know.
This is my cpp file with the death functionality for the enemy. The offending timer is commented out towards the bottom. Also note the UE_LOG that says “Pre-Die” is not being reached with the timer in my code, but “Take Damage” is being reached. As soon as the enemy should die, the game crashes:
The callback function for the timer just calls Destroy():
In the EventGraph for the EnemyAnimBlueprint, I’m calling the DeathEnd function from the AnimNotify, functionality is in C++ in first screenshot:
This is where the DeathEnd notify is, in the animation montage that I’m playing from C++:
Like I said, everything works perfectly if the timer isn’t being set, just after the enemy dies he stays lying there forever, so I would love to figure out why my timer is causing the game to crash.