Hey, I’m having a problem with respawning my player character after destroying it. I have an AI enemy that chases you and if she catches you it will destroy the player character and meant to spawn you by a blueprint actor that is placed in the world. But when they player character is destroyed it goes to i assume is the origin of the world and spawns under the landscape and there is no input. But this only happens in the main level that the game is run on, but on the test level that I have it doesn’t have this problem. I tried many ways of respawn the player and it does the same thing every time. I have no clue how to fix this. And what is the problem. even when I destroy the the player with a trigger box it does the same thing. I have tried changing the collision settings on the SpawnActor that didn’t work and I have been stuck of this for about a week now trying to fix it
This is in the ai event graph
This the error message I get.
I have attached the video with a google drive link so show what is happening. I cant find a way to upload the video here
Get the spawn transform from the player character ( and put in a variable ) before destroying the player. You don’t need the cast.
( I can’t see what you’re passing as param to ‘get actor of class’ )
1 Like
This KillPlayer function is inside of BP_Enemy? You mentioned you want other class be responsible for respawning your player, but you’re already creating the BP_Player and possesing it in your KillPlayer function, are there any more functions for respawning that you’re trying to run?
About the errors, the first one is happening in “RespawnPlater” node inside of BP Player, so we’d have to see more of what’s happening there.
The other errors are that GetActorOfClass returns None, meaning it can’t find object of this class inside of current level, are you sure you have put object of this class somewhere in the world? I am guessing right now you just want to use this BP_Spawn as a place to put in the world to later get it’s transform for spawning player as showed in the function. Kind of just like in default template there’s PlayerStart put somewhere (which btw you could use instead too if you were just taking it’s transform).
When it can’t find the object it’ll spawn your character at location 0,0,0 which makes sense what you said.
When you destroy a character (Pawn class) the controller un-possesses it. When a new pawn is created the controller needs to possess it.
When a Player is killed you should re-use the character. Go through all the normal ragdoll, movement logic, un-possess etc, then teleport it to the respawn location.
On respawn, re-enabled the character and then possess it.
Possession events need to happen in the Game Mode.
1 Like