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?

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.

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?

yes! but you see, that’s my original question regarding the player start actor. if I have to use the spawn node for spawning the character/pawn that I want, then the player start actor isn’t of much use, I could just use a dummy or any invisible actor to get the coordinates for spawning the character or even set the spawn transform in a variable inside the blueprint and no actors in game. in fact that’s the first thing I did, and it works, but that’s what made me wonder about the player start

since the player start actor always spawns the default pawn, I was wondering if I could make a script to set the default pawn appropriately before the player start runs.

If my game mode has no default pawn set, and I make a simple script inside the game mode blueprint like this: on begin play, set default pawn to mycharacter, it won’t work, won’t spawn any characters, so I assume the player start actor runs before the game mode is able to set the default pawn

I’ve seen some of it, jump searched for something that could help me out, but it went through some multiplayer stuff and, quite frankly, things that right now it’s out of my reach, since I’m an archviz artist trying to make sense of ue4 to behave like I want on my archviz scenes.

however while watching it I saw some node that made me wonder about another node and so I looked for a restart player node and it exists, so I just added it after my set default pawn node and it worked! so it was really helpful after all. also saved this video for future reference, there’s a lot of ideas there which can be useful for different situations

so case closed, thanks a lot man

oh btw, this is what I was using before:

and this is what I’m using now:

both are small codes and do the same, but the difference is that now the player start actor actually serves a purpose of spawning the default player rather than being just a reference for transform coordinates.

cheers

IMO the whole Game Mode thing in UE is a mess.
It’s not intuitive at all for new users, and even once you get how it’s designed you never get the feeling you are working with something that follows a proper logic.