Download

[noob] Difference between Actor and Pawn ?

For the moment i don’t understand…

I read in the doc that a Pawn can be “possessed” by a Player Controller class.

But i read that the “possess” function only works on server for multiplayer games.

So, should i conclude that a Pawn is only useful in multiplayer games ?

As far as I understand (I’m a beginner myself), an Actor is your base object for pretty-much every game object, whereas a Pawn is a type of Actor that can be controlled by either the player or an AI system. You’ll want to use Actors for things like tables, doors, lamps and various other objects within your game, whereas you’ll want to use Pawns for things like the player, monsters, non-playable characters and anything else that’s seemingly ‘alive’ within your game!

I think that’s the basic idea, but perhaps somebody with more experience can elaborate on this more…

I understand the idea but technically i’d like to have a list of functions added to Pawn subclass.

An Actor is something you place in your world.
A Pawn is a special Actor because Controllers(= Humans and AI) can possess them and feed input to them.

A Pawn IS AN Actor

Nvm.

Player Controllers only exist on the owning Client and the Server.

For example Client A has only one controller in his world and Client B has only one controller,too.
But the Server can access both of them.

So if you play with another player, your client machine can’t access the Controller of Player 2 (for example getPlayerController() with an ID > 0 as input) as it will return NULL.

A Pawn is a child class of an Actor, which means it inherits all the traits that an Actor has along with adding it’s own traits.

So all Pawns are also Actors, but not all Actors are Pawns.

A Pawn is useful in ANY game; I think the documentation is just saying that possession (the process of assigning a controller to a pawn) doesn’t work on client PCs within a multiplayer game (i.e. it’s up to the server PC to assign the controllers to the pawns). In a single-player game, the PC you’re running the game on IS the server, so it absolutely applies!

Like everyone has said on here, a Pawn is simply an Actor that has functionality built in out-of-the-box, saving you from having to implement it yourself. If you want to make a character in your game, you create a Blueprint class using the Pawn class as a base, and then extend it with your own functionality to make it behave exactly as you want. You could even look at the Character class, which is a special type of Pawn with functionality built in for walking, running, jumping and swimming!

So, in short, a Character is a type of Pawn, which is in turn a type of Actor.

Ok,

What i’m testing now is creating functions in the Pawn, so Player Controller can say “do this” to the Pawn

But i can do exactly the same with an Actor class

So, do you have a list of buil-int methods added to Pawn class, that makes its control easier ?

Maybe i’m starting to understand…

I removed the keyboard inputs from PlayerController subclass and paste them in Pawn subclass.

The “possess” method on PlayerController gives the keyboard focus to the Pawn.

Now i’ve still a problem in PlayerController, the method “Get Player Pawn” still doesn’t work, so i gotta use “Get All Actors of Class” method instead

^The Controller has a function “get Controlled Pawn”, which returns the currently possessed Pawn.
Don’t use “Get All Actors of Class” though, the order within the array is unreliable and the function itself is very heavy (because it iterates over ALL Actors in the world, which means it also iterates over Static Meshes etc.)

I call “Get All Actors of Class” in the BeginPlay event, then i possess the Pawn at index 0.

I didn’t find another way to find a reference to the Pawn in Controller class.

^As I said, a controller already has a reference to the pawn it possesses.
Call “Get Controlled Pawn” in your Controller.
Your method wouldn’t work anymore as soon as you place enemies in your level, because they’re pawns, too (controlled by AI).

Okay, thanks.

The trouble is that i don’t have a controlled pawn when game starts.

I had to put “default player pawn” to “none”, because when i put “default player pawn” to “mypawn”, i have a strange bug in .exe version, the player pawn is duplicated at coordinates (0,0,0)

“Get All Actors of Class” works, it sends back a one-cell array, because i do not say it “Get All Actors of Class Pawn” but “Get All Actors of Class MySubclassPlayerPawn”

Noob myself too, i got that actor are all objects and paws are posses-able actors (player, npc’s, monsters and birds…etc) but where i lose my foot it is in what it is the difference between a pawn and a character

Accorrding to documentation character is subclass of pawn which in turn it is a subclass of actor, but if i, as a player, posses a pawn, thus been a player character (the pawn), Where that leaves the subclass character? because i am not playing with a character but with a pawn… Hope someone understand what i am saying… :slight_smile:

Noob myself too, i got that actor are all objects and paws are posses-able actors (player, npc’s, monsters and birds…etc) but where i lose my foot it is in what it is the difference between a pawn and a character

Accorrding to documentation charactjavascript://er is subclass of pawn which in turn it is a subclass of actor, but if i, as a player, posses a pawn, thus been a player character (the pawn), Where that leaves the subclass character? because i am not playing with a character but with a pawn… Hope someone understand what i am saying… :slight_smile:

What exactly do you want? The Character class is indeed a subclass of pawn. THe Character has a built-in movement component and has prediction code implemented.
It’s basically the same as a pawn, just with some predefined behaviour.

I start to got it… Pawn has some automatizations to interact with environment like:

  • Pawn has an automatic reciproc reference with ia & player controllers, using methods as “get controlled pawn”, “get controller”, “get possessed pawn” etc… controllers can change pawn with the “possess” method.

  • The Pawn posessed by Player Controller makes automatic focus on the camera stored inside.

  • There are 2 ways to start with Player Pawn instance possessed, you could not do with an Actor. 1/ in game mode set default player pawn to your class, the instance will be automatically generated (at coords 0,0,0 / in main camera / at playerStart object) or 2/ drag a pawn instance to the schene, then in instance properties (“details tab”) set “auto possess player” to “player 0”

Forget what i wrote, i realize what i said was true for version 4.13.2

But the default pawn generation has been removed in later versions.

Only two methods now:

  • drag it on map and set the instance “auto possess player” to “player 0”

  • instance it yourself with script