Coming from Unity- Pawns and Controllers.

Before using UE4 I had been using Unity for about a year. We had finally decided on a game, setting, gameplay, controls, and flow when we stumbled across a show-stopping bug. So many of my future posts will be written with Unity in mind.

Unity is based around gameobjects. Everything in the world is a gameobject; these gameobjects have attached scripts which are executed in a fixed order. They also possess a transform which is their position in the world. One possible setup for a player character could be a gameobject with a renderer, a model, a transform, a collision mesh, and various control scripts. In our case we had one script to control input, one to handle player states / health / current equipment, one to handle slow motion, and so on. The camera was a separate gameobject that had its own script to follow the player.

UE4 operates on a different system, the Pawn Controller system. In this you have Pawn blueprints, which operate similarly to gameobjects. They have a position, model and collision mesh (much like in Unity); however they can also have a camera.

The Controller blueprints work a little differently; they also have a position and facing, but they “possess” a Pawn. Possession means that the controller takes control of the camera attached to the Pawn. It also passes input to the Pawn which the pawn then turns into movement/actions.

So what does all this mean? You can have several pawns lying around, doing nothing, until you set a character controller to possess one. The camera attached to that pawn will be used, it will start receiving input and you are good to go. At any time you can move your player controller to another pawn, which will change your camera, send that pawn input and so on. This is a neat way of implementing a change in control scheme and camera when your character gets into a car, for example. It also helps in multiplayer games, where you don’t need to spawn multiple cameras as they are attached to the pawns, and each controller can take input from different sources, but the code in the pawn can be the same.

There are extensions of this in the AIController, which I’ll talk about later.


1 thought on “Coming from Unity- Pawns and Controllers.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s