player start: what's the point?

so I have 2 characters in my blueprint, a pawn for VR HMD/motion controllers and a character for gamepad/screen. they are not positioned in the world, I just set my level blueprint to spawn a different character if I have HMD enabled or not. I needed a transform to spawn them into, so I added a player start into the world and referenced its transform in my blueprint. it works, but the player start spawns a sphere, which googling about it revealed that it’s the default pawn.

why is player character spawning a default pawn when I’m spawning another character/pawn? what am I doing wrong?

This is a series I made about blueprints that covers a lot of the basics for people getting started. Check out video #19 it goes over the “game mode”. This is where you set the default pawn, controller, HUD etc for the level you are in. A player start will always spawn the chosen “default” player pawn for that level based on the game mode’s definition of what the default is set to. You don’t really need a “transform” to spawn the character in if you use the player start. It will auto spawn the appropriate character if you switch the game mode based on whether you use the HMD or not.

hey, I watched your vid, thanks for that

so basically, instead of making a script to switch characters I’d have to make one to switch between different game modes with the character I want as the default pawn? should I script this inside the level blueprint?

i would script it in the game instance because it persists between levels so changes you make in a “loading level” will carry over. It can also easily be accessed from any other blueprint using the “get game instance” function call as opposed to the level BP which is much more challenging.

understood, makes sense.

but how to dynamically load a different game mode when starting the game? is there a node to set game mode? I couldn’t find how to and searching a bit revealed that game mode can’t be changed while the game is running. perhaps when launching it can choose which one to begin, but how?

Gamemode doesn’t have to contain just ‘1’ game mode only…
There are BP nodes that let you get the command-line string…
But they don’t work in the Editor/PIE iirc so testing is a PITA!

ok I don’t get it anymore. let’s start again:

the only thing I want to do is, when I start the game, check if HMD is enabled, and if not, then spawn my character 1 named say “ScreenCharacter”, and if it is enabled, then spawn my character 2 named say “VRPawn”.

where do I put this script? the level blueprint? game mode blueprint?

I’d put it in the GameMode. You can assign your default GameMode BP class for every level, but you cannot have a “generic” Level BP class that serves as a parent to every Level BP.

So if you put the script in the Level BP, you need to copy it to every Level BP in your game. If you put it in a custom GameMode (or GameModeBase), you can just script it once and set the default GameMode to your custom GameMode.

ok, now how do I spawn it? spawn actor node requires a transform, and I can’t seem to get the transform of a player start actor from inside the game mode blueprint

Haven’t tried it myself but you should be able to get it using Get All Actors of Class and taking the first element from the output array (assuming you have only one PlayerStart actor in the level).

ah yes, forgot about this node. well it works, so thank you!

An actually more relevant question: if the player start actor always spawn the default pawn in game mode, then what’s the point anyway? why no just drag the default pawn into the level instead of a player start?

Because you can change the “default” pawn and still have the new pawn spawn in exactly the same location without having to delete the character you dragged in and replace it with the new one. Imagine if you had a character selection menu…you can’t have a character already in the level because you don’t know what the player will choose. Having a “player start” allows you to determine where ANY player character will begin in your level without having to specify which character it is before hand.

This makes sense, I thought that was the case, but how do I actually change the default pawn via blueprint?

I currently have my game mode’s default pawn set to none, and a dummy player start actor dragged into the game just as a reference for transforms. then in my game mode blueprint I have a “spawn actor of class” on begin play, and a branch for if head mounted display is enabled then spawn “VRpawn” and else spawn “gamepadpawn”, and then I use the player start transform as a location for the pawns to start. this is not very intuitive, I should be able to just change the default pawn on that branch instead of spawning an actor, however I googled how to do this and didn’t find anything, only found that you can’t change the default pawn while in game, and I’m not sure if on begin play counts as already in game or not. so how do I do this properly?

I have never done it but who says you can’t change at runtime? Looks like you can. Of course you can’t do this once a level has started as the default pawn will have already been created but. You should be able to do it in a menu level, store the new default pawn class in the game instance or something and then pass it along prior to opening up the first level.

Epic just ran a Livestream last week with:
Gamemode → HandleStartingNewPlayer…
Who knows it might be just what you want.

I see. but the thing is that I won’t have a menu as this should be an archviz scene.

I just want it to spawn the VR pawn if my HMD is enabled, or spawn the first person character if HMD is disabled.

I added a branch node on begin play to set the default pawn accordingly if HMD is enabled, but I coded it inside the game level blueprint, and when I started the game, the default pawn had already spawned, so I guess this code should go somewhere that loads before the game mode. I tried inside the level blueprint with cast to game mode, but no deal too, so I assume this only works if you have a menu before loading this level?

that’s quite a long stream, do you know the time code where they talk about this?

You can watch it from here

But in your case much of the Livestream (after the community intro) is about creating a custom player-start / spawn-point class, so you might find it interesting. Outside of that as regards generally solving your original point, you can just code it all in Gamemode anyway…

You can prevent Pawns from spawning at game-start just by blanking the Default-Pawn-Class in Project-Settings → Maps & Modes and setting it to ‘None’… Make sure that the Level itself has no Pawn-BP-Actors too! Then just add logic in Gamemode → Begin-Play that contains a Branch to detect if a HMD is connected or not, and then spawn and possess the appropriate Pawn after that. No menus are needed. You don’t even need a Default-Pawn type or Player-Starts (Notes work fine as well).