Download

Player Controller Examples Are Lacking

I went through quite a few project examples and can’t find one that uses a player controller in blueprint form. I tried the shooter game example to see what the C++ code looks like, but I quickly realized I have no idea what I am looking at. I do have some programming experience, but it isn’t quite translating as well as I would hope so I will try and fill in the blanks with you guys. :slight_smile:

From my understanding a player controller is really needed for a multiplayer game. It will allow you to have persistent information attached to that player and allow for switching between pawns (character, spectator, car, etc). In the shooter game it shows the controller handling MUCH more, but I can’t find where the functions are implemented. They also have a spectator PlayerController. You are also switching between different PlayerControllers?

My thoughts were On the controller: (On X Keypress) -> (Custom Event)
On the pawn: (Custom Event) -> (Pawn Specific Implementation)

If that is true, is that all that the controller is involved with for input? Does anyone have any screenshots they are willing to share that shows implementations of certain things? The player controller is the most confusing part of the engine.

That’s pretty much exactly how I’m handling it, expect the custom event only gets ran on the pawn if it requires replication. For some reason if you command the server from the controller, it’ll only replicate to that specific controller. I may have not done it correctly though…

There’s an entire section in the documentation on the player controller, there’s a player controller in the blueprint first person template, there’s a player controller in the blueprint 3rd person template, and there’s an entire series on youtube that goes from a blank project to a full 3rd person shooter not to mention a zillion other videos.

As well as Multiplayer games, it also allows you to have Pawns that can have either human or AI controllers and lets you move between control of multiple pawns.

If you’re making a single player project then there’s nothing wrong with having Input events in the Character Blueprint. If you possess a different pawn then the previous one’s Input events will cease to fire, so it takes care of some of the work for you.

The docs only have a couple paragraphs explaining what it is for. I know what it is for, just not the best practices on how to implement it, and I can confirm that the 3rd person only has player controls set up, not a player controller class. If you could point out a video that demonstrates how to use the player controller class, that would be nice. :smiley: