Pawn and Player Controller

Hey !

Assuming I want to make a twin-stick shooter from scratch (not starting with the template), I would have a Pawn that represent the ship and to allow the player to control it I would need a Controller, more specifically a Player Controller.

Where should I put the code required for the Inputs ? In the Controller Blueprint or in the Pawn Blueprint ?

Thanks in advance !

I like to have my input in my controller. I use custom events MoveLeft, Fire etc. in my Pawn and call them from the PlayerController.
The general idea is that an AIController may want to use the Pawn so try to move your user input to the PlayerController.

For small projects without AI etc. I sometimes just use the input mappings in the settings and don’t bother to use the controller for user input.

In UE3 player inputs were handles in PlayerController. However in UE4 usually player movement and actions are handled within the Pawn class itself. This allows use to have multiple Pawn classes which move/act differently and easily switch between them as each of them has their own implementation for inputs.

However as@ pointed out, this will prevent you from using this Pawn as an AI pawn. But there is a work around. As @ suggested, create a new Pawn class (called Ship) and add functions for moving left, right, fire… Then you use this Pawn class when used with an AI controller. But you should create a new Pawn class extended from Ship class for your PlayerController called PlayerShip. This PlayerShip class will accept the player inputs and call the functions in Ship class to actually move or act according to inputs. This way you can use the Ship pawn with AI Controller (who will also call the functions to control the Pawn and its actions) and the extended PlayerShip with Player controller

Thanks for the idea :slight_smile: However I think it might be better to have a Ship Blueprint Interface (if it’s the same than an Interface in OO programming) and then 2 Pawn, 1 for the Player and 1 for the AI, implementing this interface.