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 player to possess it.

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

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

Checking log file i’ve found that by spawning 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 - Epic Developer Community 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 Character actor so that i can identify which Character actor is which ( default actor has a 0 value, and second one’s value is 1)

this is 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 2 character is destroy during runtime and all i’m left with is 1 Character and 2 Controllers.

Hey tremor_al,

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

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

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

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 Set View Target with Blend (this isn’t currently doing anything, because PlayerController at index 1 doesn’t exist yet). Then you can use Create Player node with Spawn Pawn enabled. Your new player will have it’s own pawn, its own controller, and its own player state. resulting new pawn will be created right beside 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 controller you just created).

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

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