Just as the title says, how do you go about making player 2 use a different character blueprint than player 1? Let’s say player 1 is the host, who has created a listen server - and player 2 joins as the client. I see how to make the default character class, but I don’t understand how to change what character blueprint is used based on player index. Can anyone help me out here?
Hi, i feel it’s an area where the engine lacks flexibility : same PlayerController, HUD, Pawn for every players. However for the Pawn class (and only the pawn class unfortunately) you can set it to none and then you can set in the GameMode with the PostLogin event which gives you the player controller that connects to the game. From this event you can tell the PC to possess the Pawn that you want. Im pretty sure it’s a lot better/easier to use c++ to do this kind of stuff because right now BP lacks many things concerning the GameMode.
Just so I’m sure I understand: I should make the defualt pawn class none in the game mode blueprint. Then in the graph I should create two serparate sets of nodes to tell the game which character bp each player should be using. The node I should start with is postlogin then get a player controller node (one for index 0 and one for index 1) and then use possess > spawn actor of a certain class?
Yeah you take the PC from the PostLogin event and tell it to possess your pawn. The way i did it was to have a Index int variable that increment when the event is send. One issue tho is that is depends on the order that the players connect. So maybe you should have a variable in your PC that is the Pawn Class to use, and so inside GameMode you take PostLogin PC -> cast it to your PC custom class -> spawn actor from class (use the class inside your PC) and you possess the pawn.
When you say “PC” you mean player controller, right? Unfortunately I’m not at my computer right now but I didn’t realize you could make a custom player controller with variables and a bp graph.
For the order in which the players connect, the host with a listen server will always be player 0, correct? Then as they connect it goes 1, 2, and so on. Is there a way to limit the number of people allowed to join through blueprints? I only want the host and one client to be in the game.
i think you can set the max connections of a session when you use the Node: Create Session of the Online Subsystem
Hello, try this:
Assuming you have BP_Player1 and BP_Player2, both being Pawn/Characters blueprints.
In the two Blueprints, on the Event Begin Play, enable input (This makes the Blueprint listen to input, imagine all blueprints listening to input? that would be heavy):
Spawn each Blueprint on the Viewport (This will make 2 instances, on of each Blueprint):
Once you place each spawn, clic each one of them, then look for “Pawn” section, then set what player you want to be attached at “Pawn” section in the “Auto Possess” part:
I haven’t tested it myself but I think it will work.
Try and let me know
Please note you still have to place a Camera ONLY ONE, I’m not sure how to split screen, (Drag it from the toolbox to the Viewport), and then go to its properties, and set what player the camera must point to,
You can then use the Level Blueprint to move the Camera wherever you want using Set World Location, and this way your Blueprints won’t need to have a camera inside!!.
Hope this small guide I made for you helps you out!
Hey Rockseller thanks for the tutorial, it didn’t work properly though. Could be an issue with the camera. The project I’m working on is a third person and the two different character bps have cameras inside of them. Player 0 (host/server) works fine, but player 1 (client) doesn’t work at all.
I also tried what you said Raikoh but I don’t really know what nodes to use or within which blueprints to use them.
I made a new map to test it - it seems like maybe the game doesn’t label the client as player 1. Setting the auto possess on the first character to player 0 works fine, but setting the other character to auto possess player 1 makes it so that the screen of the client is set at 0,0,0 on the map with no character.
That works nearly perfect Raikoh! However the cast fails for the server. If i test it with 2 players: the server starts with no pawn and a camera at 0,0,0 - client 1 starts as the male char and client 2 starts as the female char. I’m trying to get the server to start as the male and client 1 to start as the female char.
You should honestly make it so that the server isnt a player at all, and where it’s separate and that both players are just connecting clients. It makes all this less annoying to work with. this way you have a clearer mental picture on what needs to happen. Working with mp and having player 1 act as a listen server, works quite bizarre. i have not figured it out entirely, it should work similar to a dedicated server but it doesn’t. and i’ve never gotten that to work in a packaged game, just separate em.
Edit <3 IronCorgi, i forgot about that project, i need to update that thing!
Im assuming you are using a listen server, so the issue is that the player playing on the server(listen server) doesn’t send a PostLogin event (if im not mistaking) so yeah my stuff doesn’t work for listen server :(.
edit : ok this should work
the players are in the right order but the playerstart are not (they need to be ordered).
That’s okay I’ll just make them have to set up a server first before being able to join up together. Now I just gotta get the replication working. (answerhub link)
Aside from that though this is definitely the way to go and works perfectly thanks a lot everyone.
I edited my previous post, it gives you another way to do it.
But does it work packaged ? I haven’t got listen servers to work yet with this kind of possession. If it does that’s pretty sweet.
I have no idea, i haven’t look at all the package game stuff yet, im scared to look at it now if stuff break with it
Hey guys, it absolutely works! (I owe you big time Raikoh) For packagin though… I have been trying to figure out how to make it work. I don’t understand how it works at all. I was hoping to take a shortcut and just have to do it with console commands - but I can’t even figure out how to allow use of consol commands with the packaged project. I’ve set the console command keyboard button to “`” in the input section of the project settings - but it still doesn’t show up in the packaged version.
Hey guys I know this post has been dead for a while, my question is using Raikoh first image, my character blueprints do NOT spawn at designated Player Starts. They spawn on-top of each other.
If anyone can take the time to get back to me with an answer, that’d be great !