Cannot cast after respawning my pawn

Hi Everyone,

I have a respawning function that is called after I destroy my pawn. After the respawn function called, I start a new function that cast to the pawn blueprint and I can see that the cast fail but I don’t understand why.

Here are the blueprints:

The destroy call of the BP_Bob

The on destroy event:

Ther respawn method:

And last but not least a piece of the method where the cast fail after the respawn:

Because the cast fail and I don’t manage it I have the following error:

Why is that ?

If more information are needed I can provide more screenshot.
Regards

I see some dodgy timing here

The destroy event is passing the pawn ref to ‘respawn player’, which waits, and then tries to read the class of what is on the garbage heap by now. Even if it didn’t wait, the old player is still probably in garbage collection.

Just an idea.

Presumably the “pawn” is destroyed after the delay, so the “get class” isn’t going to work, so the “spawn actor” likely fails.

You should add a few print strings to see what it actually returns and what you actually get.

2 Likes

Hi Thanks for the answer! I have change the way I’m respawning the character using the following docs: Respawning a Player Character | Unreal Engine 5.2 Documentation
Now it works fine. The delay I had was a hacky thing as I had an issue If I didn’t put it. Thanks for the extras information you gave!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.