Death animation help

So for a while now, I’ve been trying to add a death animation to my player character somewhat reminiscent of this:


Unfortunately though, as it currently stands with my present setup, when the player character dies, the game effectively crashes and I end up with a endless amount of the same error continually repeating in the Message Log.

Based on the error messages in the Message Log, the problem appears to stem from something interfering with the camera blueprint for the player character. This is rather strange as the problem started to occur I after began implementing the various animation-related components to the death scripting, none of which seemingly involve the camera.

Specifically, the culprit appears to be the Set Collision Response to All Channels nodes, as when I tried deleting them, things returned to normal with the level properly resetting upon completion of the player character’s death animation, although without the player falling through the environment as intended.

I’m not sure why these particular nodes are interfering with the game camera, which is why I need help.
Does anyone have any idea on what’s causing this problem and how to fix it?

The error is pointing you to where the problem is. In the bp_camera when its trying to do the getyvalue stuff its referencing an actor thats pending kill. Which means that actor is currently in the process of being destroyed and is now not safe to access.

Id hazard a guess you’re calling destroy somewhere in bp_ whatever that name you’ve blacked out for some reason on your screenshot, before the death animation stuff starts.

I did originally use Destroy Actor for the death & respawning events but I removed it and instead replaced it with re-opening the current level to reset the entire level upon the player’s health reaching 0.



As you can see, there’s no mention of destroying the player character in either events or in any other area of my player character’s blueprint. There’s a SpawnActor node that should be removed from the respawning that’s a relic of when I was using the Destroy Actor event. However, since I do plan to eventually implement a character swapping system I’ll most likely end up needing it for that, so it should probably be moved somewhere for now.

With that being said though, its not the SpawnActor node causing the problem though, as everything was working while it was left in place. Rather, the problem started to occur when the Set Collision Response to All Channels nodes were added to the blueprint.

The reason I know its these two nodes causing the problem is that, as I said before, when I delete them from the blueprint, everything starts to work again. I’m not sure why but for whatever reason, disabling all collision on the player appears to infer with my camera blueprint, causing the whole thing to crash.

If you click on the links in the error log it’ll take you to where the error is happening. Can you show that bit of the blueprint? Blacking out the names in the
bueprint isnt really helpful for us to help you :wink:

The only thing i can think of in relation to switching off collision responses would be if you had the kill z set to something mental like -1. That would mean when you start to fall through the floor the engine would destroy it.

Restarting the level would also destroy the actor at some point.

Something is destroying your target to follow actor that the bp_camera is looking at basically, which i guess is the player character…hard to tell as the name is blacked out :slight_smile:

Yeah, its the player character blueprint mentioned in the Message Log. Anyways I tried clicking the links in the error log but it doesn’t really help me in trying to figure out what’s wrong.

For reference’s sake, the camera blueprint I’m using is based on the one from this tutorial video [Link].

Event Graph:

Construction Script:

Get New Y Value:

Get New Z Value:

Like you’ve done in your constructor, stick an ‘isValid’ node to check against ‘actor to target’ in your ‘GetX/Y/ZValue’ functions. That should stop it crashing at least. I think that checks for pending kill aswell which is what the errors are moaning about. If not there will be a node for that check aswell.

I tried as you suggested or at least what I think you meant but unfortunately it hasn’t fixed the problem. The error messages have gone away but the game still crashes when the player dies.

I’m not sure what other problems you have, but your death function calls “Open Level” and then calls “Respawn.” One problem could be that, when you call OpenLevel, that should destroy all actors on the current level. When you call “Respawn,” the character instance calling the Respawn function no longer exists.

If its still crashing then theres probably somewhere else in the code its trying to access that actor thats pending kill. No error message? Nothing in the log file?

Did you check the kill z value as you say it only crashes when you fall below the ground? if not try Settings > World Settings and disable ‘Enable World Bound Checks’. Long shot but you never know.

If you remove the open level node and let the player die and play the animation without restarting the level does it still crash?

Is there a reason you’re using a separate blueprint for the camera? You could just add a springarm component and a camera component to the player character.

I want to point out that when you get an error regarding a pending kill, it’s saying you’re destroying the actor, and then trying to run more code after the fact. You need to make sure that the destroy self is the last node you call in any chain of events, and if necessary, add a delay to compensate for any time the code might take to complete running. For example, if you were to do something like a ForLoop and then Destroy self immediately after, you might want to add a delay of 1 second before the destroy node to give the loop time to complete. That’s what the error message is saying.

Also, there’s no need to restart the level every time the player dies. I’ve seen people do this a lot in tutorial on a respawn system but it’s mostly unnecessary. Just move the player back to the location of the player start. It’s a lot easier.

Skip to 11:40 in the video

Okay, I think I’ve finally made some headway into what the heck is going on.

I decided to start an entirely new project from scratch and recreate most of the death events to see what would happen, independent of all the other blueprints I created in my main project.

And just like my main project, the game would crash (although crash might be the wrong terminology) upon the player character dying and falling through the floor. However, it would appear that the Set Collision to All Channels node was not the direct cause of the problem, sort of. You see, when I removed the Delay node from the setup, suddenly the restarting the level upon death events were working again.

It appears what is happening is that Unreal Engine 4 by default will automatically destroy the player character very quickly if they fall into a bottomless abyss, thus when I try to deliberately cause the player character to fall through the scenery, the engine destroys the player character before the rest of the blueprint can finish executing. This would explain why I was getting error messages related to issues stemming from destroying the actor despite the fact that I removed all references to the Destroy Actor node from all of my blueprints.

So the question now is what can be done about this? I can easily respawn the player character when they fall into a bottomless pit via a kill plane as the events can be quickly executed in less than a second. Unfortunately, my intended death animation appears to take too long before Unreal will automatically destroy the player character, causing the game to crash or whatever.

Since the issue appears to be a lack of instructions upon the Unreal destroying the player character after falling into the abyss, I was wondering if there’s a On Destroyed event that could be used to replace the Respawn custom event & just have the player character get destroyed at the end of the death animation.

Alternatively, since I planned on being able to switch between multiple different characters, I’m a using Player Controller blueprint, so I was also wondering if that could be used in someway.

I’m not sure if any of these ideas are good or not but I’m not really sure what else to do, so any suggestions would be greatly appreciated.

set the kill zone value to very low level

like -99999997952.0

1 Like

Thanks a lot! That worked like a charm!

However, while playtesting I’ve run into a minor glitch that I’d like to take of.

I discovered that my player character doesn’t ignore all collisions upon their health reaching 0 when my player character started bouncing off the head of an enemy strolling by, which shouldn’t be happening. The player character during their death animation should be able pass through everything. It’s not a big deal since the level resets after a short period of time but its something that I’d still like to fix.

Wow I told you to check the kill z in two separate replies…

I dont know why i waste my time sometimes…

A picture is worth a thousand words :joy:

btw, When I was a teacher of Unreal, I remember the very first thing I taught was the kill z

1 Like

Oh, I didn’t know that Kill Z meant kill zone, I assumed that since the camera blueprint was being brought up that Z referred to the Z-axis. In all my times with Unreal Engine, I’ve never heard that term before, and as a result, I had no idea what a Kill Z was.

No worries, apologies if my reply was a bit aggro, bad day :slight_smile:

Does anyone know how I can go about addressing this particular issue?

are you check the physical asset collision data from character or enemys?

This is what I did in that example I posted a while ago:

The “Set Collision Response to All Channels” makes the character ignore all collisions, and the “Set Simulate Physics” makes the character fall.