Pawn owner on possess, controller or null?


So was always under the impression that the pawns owner should always be the controller.
Was working on a small project to test out some functionality and it came very much to my surprise that this wasn’t the case. It was NULL.
Looking at the code I can’t find any place where the pawns owner is set during possession.

Was this always the case? I’ve been working with Unreal for a long time, back to UE2, so i’m pretty confused about this :D. And I have always been under the impression that the pawns owner will never be null when possessed.

The docs seem to say that it should be the controller →

One example of this is when Pawn actors are possessed by a PlayerController. Their owner will be the PlayerController that they are possessed by. During this time, they are owned by the connection of the PlayerController. The Pawn is only owned by this connection during the time it is also owned/possessed by the PlayerController. So as soon as the PlayerController no longer possesses the Pawn, the Pawn is no longer owned by the connection.

This pull request seems to suggest that this is actually a bug:

The owner of a pawn should by default be its Controller. Nearest I can tell this setting occurs on Possess, and on UnPossess it clears the owner to ‘NULL’. If you wish to go away from using the controller as the owner you have to force it every time you UnPossess and Possess the pawn. Also important to note you have to delay overriding the initial owner because when you spawn an actor it doesn’t get possessed until the following frame, and overrides anything you do immediately after, or as input in the Owner pin, to the Spawn Actor From Class node. In C++ This is even more of a headache, but personally I think spawners are best done in blueprint scripts for designers to utilize timers and level events simply.

1 Like