Download

Is it possible to assign player index manually on spawn?

Hello guys!

I have little problem in my shmup game. Right now I have respawn event created based on this:
https://docs.unrealengine.com/en-US/Gameplay/HowTo/RespawnPlayer/Blueprints/index.html

Here’s my blueprint:

Everything was alright until I made certain enemy attacks (where they are shooting at player):


Problem is, when player get killed and respawn, player index in “Get player pawn” changes. After that, naturally, log gives me this:

I tried to change “Get player pawn” to “Get player controller”. This eliminated errors but enemy bullets were flying in a very weird way, not at the player at all.

So this leads to my question from the topic title: is there any way to force player pawn to keep same player index, even after “destroy actor” and respawn?
Pretty please, help me somebody! :wink:

PS. When I plugged “print string” node to “Get my player index” it says “-1” all the time, even after respawn :expressionless:

You could rumble through all the pawns with a foreach, casting to find the player. Or, what about putting an actor tag on the player, then you can use GetAllActorsWithTag? ( maybe )

Thanks for tips but I made it the hard way :stuck_out_tongue:
I was struggling with this problem for few days now and I had to give up. I mean, I gave up on solution I described above. I rebuilt quite a lot of blueprints and whole respawn system. Right now instead of destroying player pawn on death (as the documentation suggested), I’m just playing the blueprint from the very begining. Player index stays the same, logs are clean as a whistle. :slight_smile: