InputComponent on Character Destroying Itself?

Ok, here’s another mysterious problem…

I’ve got this revival-functionality in my game, where a player that has already been unpossessed and gone ragdoll can be revived and the original player controller (who is temporarily possessing a spectator pawn) takes back control of the character.

In singleplayer there’s no problem. In multiplayer the revived character doesn’t respond to input from its client anymore.

I tested a lot. First I learned that InputComponents only ever exist on the client (or listen server). Then I tried to narrow down the problem and found that the client’s revived character’s InputComponent is suddenly set to NULL after taking control again. All the code that turns the ragdoll back into an animated character is executed (on the client) before the client’s local controller possesses the character again and at that point the component is still there.

That makes me think there’s something going on inside the engine that destroys my InputComponent. I definitely didn’t write any code for that…

I do have some other situations where player controllers switch from one pawn to another (including from and to the same character-class used with “reviving”) and there are no such problems.

Does someone understand what’s going on here?

EDIT: I know now that the input component on the character only gets destroyed on the client, if I also destroy the spectator that the player was controlling in the meantime in the server function that calls possess. Bug or feature?

1 Like

Uhm ok, I solved this myself:

PlayerController->GetPawn()->Destroy();

PlayerController->Possess(Character);

… works fine

APawn* spectator = PlayerController->GetPawn();

PlayerController->Possess(Character);

spectator->Destroy();

… is how I did it and leads to the Character’s InputComponent being destroyed.

Don’t know why this is happening, but maybe it should be fixed. Hours wasted again :frowning:

1 Like