Player Character autodestroys if linked to DefaultController

Hi there, i’ve run into a problem spawning a 2° player at start up. This code runs inside level BP. Basically i just
create a player (without Spawn Pawn selected) >> spawn a actor at certain transform >> tell the player to possess it.

By doing this the Character object is created just fine. However the problem is there’s only one PlayerController during run time.

By checking some other post I decided to spawn a DefaultController after spawning the actor. However doing this causes the 2° MyCharacter object to be destroyed during run time after a few seconds of running the game, but the 2° MyController objects is not destroyed so I’m left with 2 Controllers and only one Character.

Checking the log file i’ve found that by spawning the default controller it results in this:

[2014.11.12-04.59.00:753][ 11]LogWorld: Bringing up level for play took: 0.001866
[2014.11.12-04.59.00:755][ 11]LogPlayerController:Warning: Calling IsLocalController() while Player is NULL is undefined!
[2014.11.12-04.59.00:755][ 11]LogPlayerController:Warning: Calling IsLocalController() while Player is NULL is undefined!
[2014.11.12-04.59.00:755][ 11]LogPlayerController:Warning: Calling IsLocalController() while Player is NULL is undefined!
[2014.11.12-04.59.00:757][ 11]PIE: Info Play in editor start time for /Game/Maps/UEDPIE_0_Example_Map 0.669
[2014.11.12-04.59.00:757][ 11]LogPlayerController:Warning: Calling IsLocalController() while Player is NULL is undefined!

…and so on… hope someone can tell me whats wrong here.
BTW if confirmed this happens in 4.5.1 and 4.6 both with TopDown BP template

Hi tremor_al,

Can you post an image of your Level BP setup? And can you describe more explicitly what you are trying to achieve with your game? Thanks!

Sure, what im trying to achieve here is doing a local multiplayer game for 2 players. Ive followed this post: Gamepads, Local Multiplayer, Dynamic respawning - Multiplayer & Networking - Unreal Engine Forums

So far all i’m doing is creating a second player → spawning a actor → possess said actor.

I’m doing this because i need to specify a variable in the Character actor so that i can identify which Character actor is which (the default actor has a 0 value, and the second one’s value is 1)

this is the only code in my project:

what troubles me is that by using this code all i’m getting are 2 Character with only 1 controller. So then I addedt “spawn defaultcontroller”, however by doing this the 2 character is destroy during runtime and all i’m left with is 1 Character and 2 Controllers.

Hey tremor_al,

Sorry for the delay in response! This issue got buried somehow and I lost track of it.

So the problem here is a misunderstanding of how the Create Player node works. When used, the node creates a new PlayerState, PlayerController, and Pawn, unless Spawn Pawn is disabled. In that case, the PlayerState, PlayerController, and Pawn will only spawn when transitioning to the next map. The screen will be split regardless, but the other players’ screens will be empty.

The way you have it now, the screen should be splitting but the Create Player node isn’t returning anything, and then you’re spawning MyCharacter and possessing it with nothing.

The way to fix this depends on what you’re trying to get. If you want local splitscreen, in which each character has its own camera, you can drop the Set View Target with Blend (this isn’t currently doing anything, because PlayerController at index 1 doesn’t exist yet). Then you can use the Create Player node with Spawn Pawn enabled. Your new player will have it’s own pawn, its own controller, and its own player state. The resulting new pawn will be created right beside the first player, but you can now reference it to either move it or destroy it and replace it with a different pawn (possessing it with the controller you just created).

If you’re trying to get a game in which all the characters share the same camera and screen, Create Player isn’t the way to go. In that case, you’d want to spawn new instances of these things manually and then use the Set View Target with Blend.

Hope that helps! Let me know if you have more questions.