Is playercontroller file == playercharacter file?

So I am currently learning unreal and unreal’s api, and I am creating a save system based on a 3hour tutorial for c++. Now everything is working and I am at the end of the video, but he is trying to make save specific code for the playercharacter.h and .cpp files, except I don’t have these. He also has a character.h and character.cpp files which I do have. But I ONLY have character.h and character.cpp. However, I do have playercontroller.h and playercontroller.cpp files, are these the same thing as playercharacters.h/cpp? I have read about the analogy that playercontroller=brain and character=body and know a lot of code for a player goes into and can go into the controller source files, but I am not sure if these are the same thing as a playercharacter file and perhaps it just got changed through different versions of unreal. If this is not the case and a playercharacter file is indeed different, why do I not have any, and how do I get them? Thanks!

hey Oxyten - welcome to the unreal forum :slight_smile:

about your question: i am not sure if i understood your question correctly, it requires more information what you are actually trying to do (paste some code or a picture here).
Generally, the PlayerController is NOT the same as the character class. The PlayerController manages player inputs, while the character uses it e.g. define functionality what happens if mouse is clicked and so on. Player Controllers in Unreal Engine | Unreal Engine 5.4 Documentation | Epic Developer Community (epicgames.com)

it seems playercharacter might be a class that derived / created from unreal character.class

1 Like

Thanks for the welcome! so, my question is why doesn’t my project contain playercharacter source files. I have (projectname)character source files, but not (projectname)playercharacter and he has both. The only difference is his video is for 3rd person, while mine is for first person. And my thoughts were also that maybe he created a character class, but WHICH class because I could not find player class as an option and that is a default unreal name for whatever class he made it with(or was there by default from using 3rd person template when creating the project) I can’t really show a specific line of code because I am not missing a line of code, I am missing the whole file lol but I can show a screen shot of the source file he is in and show my project source files which doesn’t have the playercharacter. And note: My (projectname)character.h/cpp class is not the same thing as his playercharacter class as he also has a regular characterclass. And again he is using 3rd person template while I am using first person, and if this is a c++ class he created through unreal, I can’t find the same one. As the suffix “playercharacter” to my knowledge is Unreal’s suffix, but perhaps I am mistaken on that. But again idk which class it derived from because it looks nothing like my character class, but more like playercontroller. Not that thats what it is, but they just look similar.

Also, something interesting I just noticed is he DOESN’T have playercontroller source files. But upon looking at the video and seeing what I can of the playercharacter cpp and regular charactercpp they both indeed seem like the same file, except a lot of stuff in playercharacter refrences things to the character class. Like if(Atf::CharacterCanJump()) {Atf::CharacterHasJumped();}. But I don’t understand why there is 2. It’s for a single player game. Because I could understand if this playercharacter file was supposed to be like a specific player’s code while charactercpp is the general code for all players. OR maybe charactercpp is for any character class like if your game has enemy a.i. and then playercharacter is specifically the person playing character, but if this is the case and I create a new c++ character class, how do I link it to my player?

hey sorry for the delay - and you are right!
indeed it seems that “playercharacter” is a created c++ file that derives from the character class. That is common way to do it for your “player” and/ or ais. All characterclass functions, vars and components can be then accessed from your new playercharacter script and when you create it - you can of course name it like you want. Origninally below characterclass lies the pawn class - that is often used if you dont want to use the built-in functionality of the character class or for simpler pawns scripts like simple ais.

so if you want to create such script:

  • in c++ folder in Editor → create new c++ class → choose that it is ob base “character” and click ok
    for the player controller: it is already having a controller → in header of that class it has: include “GameFramework/Controller.h”
    for any pawn or character class you can set a controller - either via your GameMode or in the detailspanel of the your derived characterscript when you create a BP that derives from your made characterclass.

in general you can see in the .h file from which class or component your script inheritates:

  • go to the header file “yourcharacter.h” → below the “include blabla” section comes the initialisation of class type etc… there stands something like:
    -class YOURPROJECTNAME_API Yourcharcter : public ACharacter

and ACharacter is the class your palyercharacter.h is made of

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.