Best way to posses posses multiple pawn at once?

Hello,

I am making a Cannon Fodder style game, where player will have a handful of units which are quite directly controlled (WASD + aim to mouse position) and will be able to switch between them. I want the switching to be a fluid process, so that camera smoothly pans from one unit to another. Therefore most obvious solution is to have one “Player Camera” style pawn, which is possessed by the player controller, and then control the individual units as well, but indirectly.

I broke my teeth on the fact one player controller can not send input to multiple pawns at once. I am using FloatingPawnMovement component to control the units. Even if I explicitly enable input on the units, and make very, very thoroughly sure that Block Input is not enabled on any actor in the scene, I still can’t get any other pawn than the Player Camera pawn to move.

I am thinking about some workarounds but they all are extremely overcomplicated. So I’d like to ask if anyone knows any straightforward, common solution to this problem.

Thank you in advance.

Alright, I’ve found a solution. Posting it here in case someone else ever needs it too :slight_smile:

First, in my case, pawn I want to control is already placed in scene, so I’ve created a reference in Level Blueprint, and passed it as variable to my primary possessed pawn:


Then, in this Pawn I’ve just created reference to, I have created two custom events as well as two variables for axis value, as even the pure axis value functions don’t appear to work when pawn isn’t possessed. I’ve used these to replace input events and their axis values:

And then, in my primary possessed pawn, I am simply forwarding the input to the pawn reference I’ve got passed on from Level Blueprint:
PlayerPawn.JPG
It’s not as clean as I’d like it to be, but it’s not really overcomplicated either, at least I hope :slight_smile:

cheers

Thanks, I’ll come back to this when I want to do the same kind of thing.
I suppose the devs at Epic feel that multiple pawns for one controller isn’t useful enough to warrant its inclusion in the engine. It would be nice to simply set the curent controller from a pawn, for as many pawns as you want.

hello, i found a solution…see if this is same as you wanted

Hi reading the given solution i thought at one that would be cleaner (maybe).
Creating the Soldier actor class which can move and shoot and just one Pawn called Army which represents the set of “Soldiers” and spreads the inputs through every Soldier which references are located in an array.
Give me feedback on why it would be ok or not, thanks !

I have a system kinda similar to this. I have one Pawn, a free-floating camera, that is possessed by the Player Controller. The level contains a bunch of vehicles, each a Blueprint Class inheriting from Actor, that I can semi-possess while still having control of the free-floating Pawn. I did this by calling Enable Input and Disable Input on the vehicle instances as appropriate. This works well.

A problem is that this doesn’t work when the vehicle inherits from Pawn instead of Actor:

LogPawn: Error: DisableInput can only be specified on a Pawn for its Controller

I would like to find a way to have the same Blueprint class sometimes act as a full Pawn directly possessible by the Player Controller and sometimes act as a semi-Pawn that my free-floating camera Pawn can control.

there really is no reason to Possess anything in this type of game, think of an RTS the player doesnt possess every unit. likely just a camera

you want to use Commands, simple way is add an interface to your Actors. keep the input on the player controller and when you press MoveForward, we loop over all ‘selected’ actors and call the interface equivalent.