ACharacter class. Is this meant for only the 'player' character or all upright human-like characters in the game?

Hi everyone. I am trying to learn Unreal Engine (I have some experience of other engines and languages) and this minor point is confusing me a little.

Basically I read the documentation about ACharacter class. It states it is for Player controller character AND ai controlled.

When I create a new C++ class which inherits from ACharacter, the pre-written code has override function named “SetupPlayerInputComponent”, but this to me implies the class is meant to receive players input (and therefore not really meant for AI controlled characters).

Can anyone help me understand the class a little better. Of course I could just ignore that function if the ACharacter I make is only an AI , but it seems odd to me to have this function forced to be there for all AI character classes.

Thanks for any help (please note I am still new to UE4 and not even fully sure how to create my own custom player input scripts yet).


ACharacter is a child of APawn class. Both of them can be possessed by players and AI.
But ACharacter is a bit extended. It has a movement component with replication.

You should use ACharacter for all human-like species in your game. But for example, to implement a drone or anything with unusual movement it might be better to use APawn.

Thank you for clarifying this.

Thats just wrong.

If you use the class or not depends on a myriad of things.

Do you need replication ?
Yes? This class does it for you.

Well then using something which has stuff you don’t need in it makes things slower to run, so you are better off coding your own class.

Does your character need physical interactions?
Yes? the class does it for you.
No? Then there’s a bunch of things this class does you don’t actually need.

Probably the best initial thing to consider is “can I code my own movement component?”

If you cannot, then the class provides the base for you - despite not being a good choice to use for all projects.

If you can, then you are way, way better off creating a component that only contains what you need.
Even if that means duplicating the character class(es) and stripping parts you do not use out of it.

Interesting comment thank you. I think I would like to try to code as many of my own components as possible so that I can tailor-make it to ONLY do exactly what I want. I agree that the classes already included in the engine may be overkill for many entities in my game.

It’s hard for me to judge it right now since I just barely understand the example-projects and I am just looking to learn. I do have a background in C++ already but majority was just SFML or Text/Console Applications that I tinkered with alone (no tutoring or help other than forums).

I guess I will give it a try for some simple AI character, to code my own “Patrol this area” script as a component I can attach to said AI entity and see how I get on.

Thanks again for all help and comments here. (I have another silly question which I am going to post separately :smiley: )

You might want to read through Pawn and Character to see what Character adds to Pawn. Historically, Pawn had a metric ton of stuff that was rather Unreal Tournament-style game centric, and a lot of that got moved out to Character over the last few years.

The odds are pretty decent that if you’re making a game with bipedal characters, you can probably get a pretty good start with Character. But for sure, have a look at the things Character adds to Pawn.