Download

How do you change player pawn at run time when your inputs are in player controller?

If I have all my control inputs in the player controller and I want to possess another character pawn at runtime. How do I go about doing that where it successfully changes to another pawn and keeping the same controls. Right now when I possess another pawn, I get no inputs since all the inputs are on the player controller. I tried to do the un possess before possessing new character pawn but it doesn’t do anything.

Is there something I do with the game mode? I’m using blueprints. Just not sure what nodes and the setup.

Thanks!

Add the desired inputs to the possessed pawn, doesn’t have to be on the pawns controller.

Thanks but the problem is that a lot of my code is in the player controller, not just inputs. Will that work too?

What I mean is like if I had other code not input on the controller would it still work on the possessed pawn?

I tried to move the inputs over and it was all messed up so I can’t do that. Would be nice if there was a simple way just to change the default player pawn during runtime.

What I mean is, if you need controls for movement create additional input movement actions, like you did with the main character.

Thanks! I’ll try just that as well!

What you have is a common setup.

  • Player controller has a reference to a possessed (controlled) character
  • Any controllable characters either (1) inherit from a base class or (2) implement an interface for movement
  • Player controller routs commands (“the player’s will”) to the currently controlled character

Then your input chain looks like:

Player presses “Left Key” … PlayerController->MoveLeft() … ControlledPawn->MoveLeft()

Thus each controlled character can implement MoveLeft() in its own way but your PlayerController doesn’t care. It just routs commands to whatever it currently controls.

I was able to solve it by possessing new characer and destroying old. Then reload map and teleport to location. Saved and loaded. Thanks all!