Having two local co op characters appear different from one another

Hello!

I’m very new to game development- so please keep in mind that I might not use the correct terminology and might have to ask for super-basic explanations!

I am currently working on a local co op, 2.5D side scroller (Think ‘Unravel 2’ kind of style!) Both players must be assigned at all times, and the multiplayer is only Couch co op. The game is a puzzle game where both players have to work together to progress!

The thing is, I have figured out how to create co op controls, but it only ever spawns in with the same character twice, rather than two separate characters. I have both the models (I think they’re called meshes on unreal), and I have created two player blueprints ‘Player 1’ and ‘Player 2’, but in the project settings, I can only equip one as the ‘default pawn’.

I’ve read a bunch of other forums, but I can’t seem to find one that ended with a solution- but here’s a few spitballing ideas that have come from the forums!

  1. Make the characters a ‘subclass’ from one another, but to be honest, I have no idea how to do that, or how that would change the outcome. :sweat_smile:

  2. Make a new world blueprint. I am currently using the ‘side scroller’ blue print, but I think I could make my own? And I have a few rookie questions about this one, would I have to redo the current side-scroller mechanics? And would this allow me to set more than one default pawn?

  3. Set no default pawn, but somehow spawn the characters in a different way? I’m not 100% sure how this would work though! :pleading_face:

Any pointers in the right direction would be much appreciated! I’m sure there’s a simple solution, I just can’t seem to find one, and don’t have the experience yet to figure it out on my own.

Thanks for reading, and if you have any questions then don’t hesitate to ask!! ^^

You have a Function called Possess

So you can do following:

When you spawn a new Pawn (it has to be Pawn, or Character as it’s a child of it) - Possess for GetPlayerController (1) ; ID 0 = Player 1, ID 1 = Player 2

That’s the way you apply a different Pawn to Player 2

Also there are multiple techniques to also still use same Pawn for both Players and just change it slightly for the 2nd Player but that should be enough so you can use your 2nd Pawn and apply using Possess Node

Thank you! I will definitely try this out! ^^

Hey there @MeadowD! There’s so many ways to accomplish this that “best practices” kind of goes out the window for “best way for your game”.

  1. So if you intended on using the Player spawners, then you may need to do something in the constructor of the player BP that changes something out on the character, like enabling a different Skeletal Mesh, or changing the color of the character, etc.

  2. You can roll your own player spawner, and spawn then possess the player 2 as an entirely different player BP, this is a bit more messy but if your game is 100% just going to be these 2 characters it’s not so bad. That said, I still recommend the next one.

  3. Creating a child blueprint of the main player class for each, this way if you need to change something on both characters you can change the parent class. If you need to change one or the other for special powers they have their separate BPs as well.

You’ll need this documentation to get started, but I recommend finding a youtube video if you’re not a documentation kinda person like me. Blueprint Class | Unreal Engine 4.27 Documentation

If I get some time I’ll write up a quick demonstration for you and it might be enough to get you rolling.

Thank you so much! This is so helpful!! I’ll definitely have a read and try to figure it out! ^^

Hey @SupportiveEntity !

I fell a little bit behind with my project (I had to remake the models for the player characters)- so I’ve only just started to re-tackle this problem, and I have a few questions if that’s okay!

First, I’m probably going to try the third method you stated- it sounds like the most efficient! ^^

My first question is about the parent class blueprint- this might be quite a noob question, but is it still possible to use if both characters have different skeletons and animations? For example: both characters idle, walk, jump, land, push, and carry objects, but have different meshes/skeletons/animations- and I’m not sure how to accomplish this!

Second, how to I spawn the different characters through this method? Is it still through the character spawners, or through something else?

I’ve had a read through the parent class document you sent, and I have a rough understanding of it through the ‘animals’ example, but I’m still not really sure how to replicate it- so it might just be an experience issue!

Thanks for everything!!

Yep! You can just keep the base logic on the parent class and then each of their animation logic in the child class. A quick way to do this is to right click your parent BP, then hit create child blueprint class, then swap what you need to on it, add new functionality and all that jazz, then voila you have your new character, with the same logic. This also means when you look for (or cast to) other classes, you can use variables, functions, and overall logic from the parent BP.



Your gamemode decides which pawn gets put through the player spawns. In this case it’s just the default third person player. We want to spawn specific characters you may want some custom logic to generate the character. When it comes to best practices, either your players are so similar you could just swap their anim/skeleton etc. in construct. However if you’re having different child classes for them I’d recommend spawning them once the player has decided what character they are going to use or when it’s decided in game who they will possess.

Let me know if you have anymore questions!

Thanks for the help @SupportiveEntity ! I have a few more questions though!

I have successfully made one character as the parent blueprint, and the other as the child blueprint: they both have their own Animation Blueprint classes and can move/jump- and have separate meshes and skeletons! ^^

I’ve tried to use character spawners, but I’m not really sure what I’m doing to be honest- and I’m also not really sure how to write custom logic! Is it in the level BP- or somewhere in the settings?

In the settings, I can set one player to be the default, but not both- so would I have to not use this spawn methods and write some custom blueprints?

Also- when you mentioned the pawns being possessed when chosen/ when the game starts- im not really sure how to possess things either; is it through the same method as the ‘Player Start’ spawner?

Sorry for so many questions, but thanks for all your help! I’ll add some screenshots later when I send them to myself from my laptop! ^^

All good! Questions are why I’m here! So player starts are kind of special rigid built in classes that in reality are amazing for most games where you will be spawning one type of character (as it will only ever spawn the default you set in the gamemode) or one that you can easily modify with it’s construction script between players. However, in your game where the characters will be entirely different, with different abilities, meshes, animations, controls, etc. That wouldn’t be as clean and you’d have to modify everything as a construction change. If it was just a color change or just the mesh/animation it could be done there.

In your case having separate classes means you can can make them do wildly different things with less work, but you have to handle the spawning of the players yourself. Since you’re only talking local coop, this is just as easy as checking for controllers and letting them join with a button, which would then spawn their character.

So I’ve got a little video series where in the first 3 episodes it does everything you need (except his is split screen, all you’d have to change is your camera).

Disclaimer: These links are to external tutorials by members of the community not affiliated with Epic Games. This said, you are liable for anything that occurs beyond this Unreal Engine domain.

Let me know if that helps out, if not and you need a more hands on kind of explanation I can make a little project up to show you what I mean!

I tried to follow the tutorial, but I ran into a few problems!

In the tutorial, he is using ‘Third Person BP’ as his ‘base’, whereas in mine I’m using ‘Side Scroller BP’ on UE4- which has lead to a few significant differences!

He’s also using the base animations, where as I’m using a custom animation BP. This lead to him having an extra option to select called ‘index’- which I did not have as an option in my Spawn Player function.

I’m not sure which one of these factors -or something else entirely!- is causing the differences, but there were a few problems with cameras, specifically an extra camera spawning under the floor- which I’m not really sure how to solve!

I have saved a version of the game with these changes, and a version without- but I’m not sure if I can get the new one working.

For reference, I’m now using the Side Scroller BP base, with two characters, one is a child of the other. When spawned individually, they can both move around without problems.

If it’s not too much to ask, it would be really helpful if you could create a project in Side Scroller BP, and give a quick demo! If you’re too busy that’s totally okay- and you’ve already helped a lot so far! ^^

I can absolutely put something together for you! I can’t make promises on the time frame since I still have to answer other questions, but this would be a great resource to show other members in the future! I usually make little demos for most questions that require a little more hands on effort.

Thanks so much!!
Timing isn’t an issue- you’ve been so very helpful, take as long as you need! ^^

Hey Entity!

I’ve decided to use the Advanced Locomotion System for extra movement- I’m not 100% sure how it works, but I’m going to try and figure it out! ^^

Will this effect the two player aspect at all, and do you know if I’ll still be able to use all the features of ALS in my Side Scroller project? ^^

Thanks!

Hey there @MeadowD! Sorry about that, been a whirlwind week for me over here. ALS won’t cause any major problems, but it may introduce a bit more complexity at the end of the day to certain actions, but nothing game breaking and you’ll be able to workaround it regardless if you can handle the art integration side well.

As for the mini-tutorial I hadn’t finished prepping the sample project but I’ll post something tonight with a bit of meat.

It’s totally fine!!

Good to hear about ALS- I saw it online and it had so many great movements that I knew I had to use it- I think it will make the game look a lot more fluid, and less beginner- I’ve already found a tutorial about how to add it to an existing project, so I should be able to make it work with a Side Scroller BP too!

And thanks again! Honestly, I couldn’t have even started this project without all your help- I look forward to see what you make!! ^^

Yep! With ALS you will of course have to modify a number of things, but really it’s just limiting it’s ability to move in 3D but retaining it’s turning and such. Almost as easy as just unbinding the forward and backward movement and unbinding the camera from rotating with the player. That said, I’ve got everything working for both spawning drop in drop out players and the simple way (if your game supports it).

Simple way first: Just having both players already in the map, downside is you have to handle their respawns as the “default pawn” will always spawn a new default pawn. It won’t differentiate your different children we made up before. Basically just have them autopossess whichever player ID and you’re all good!

that said this makes it a pain to have to either destroy player 2 as levels start if they are single player.


The significantly more work alternative (The reason it took so long was because I was trying to test this without multiple gamepads). Drop in Drop out multiplayer! Much better for games like unravel or party games.

Pre-Setup:
Create a new game mode:
image

In the level BP or Gamemode (I did mine in the level BP as maybe some level don’t need the player 2 to be there or are cutscene levels where they don’t need to have controls). All this does is create another local player (the -1 means just add one player to the current count) and it immediately spawns a player controller. You can uncheck that if you set this up in a menu prior but that’s more to talk about in depth if I finish the example project to upload.
image

Create a new Pawn:
image

The game mode is going to control what players get spawned when and only one singular time.

The pawn will replace the default pawn. It’s only there to serve as a placeholder for players before they hit any buttons.

I called this actor “PressPlayToJoinActor” for simplicity.

All it does is wait for a key to be pressed from whatever player controller is assigned to it and then it tells the game mode to spawn that player.

Now on to the Gamemode: The only thing it handles is finding where players would spawn, takes in which player has requested to spawn, then chooses a specific actor to spawn. (you could also make an array variable and have them choose from it but for simplicity’s sake I just made 2 spawns.)

Lastly, for the first player I have the camera attached to them, but not the other. This was for simplicity’s sake again, but you can make a camera that follows them both together (though that’d be a whole other tutorial so I didn’t get into it).

And Voila! 2 characters who can be totally different in ability, mesh, and even classing with drop in drop out style of play. Just need to hit any button on the gamepad

Let me know if you have any questions about the process! We basically circumvented the normal UE spawning system a bit so you would have to handle respawns and such yourself.

Hey @SupportiveEntity !

I ended up not using ALS, because it was a bit too complicated for me as a beginner!

I also ended up following the first half for a few reasons, mostly because the game is going to be solely coop, and the first was a lot simpler; however, I was actually following the second one to begin with, but I couldn’t follow it exactly because I didn’t have the ‘spawn local player’ function- I only had ‘spawn player’.

It’s not a problem though, as the first half works perfectly for the game premise!

I haven’t been able to get it to work yet- so I have a few questions!

  1. you referred to the characters as children. Originally, I had one character as a ‘child’ of the other, but should they both be children of another BP?

  2. I was able to set the player IDs, however, only the player tagged to ‘Player 0’ actually worked and was able to move- the other would just stand beside them idling.

  3. did you change anything in the project settings or BP for this method?

I actually ended up messing around with the project too much and deleted something I shouldn’t have which pretty much broke the game :skull: It’ll probably take me a little while to set the characters up with their animations again- but this is just part of being a beginner in Unreal haha ^^

No worries! That’s half the reason I was going to make this a full example project instead of a little short tutorial, there’s a bunch of quirks to this which you would only ever know after playing with it for a while. So I’ll address your questions first and get you working, then I can go over anything else you might need.

  1. Yes I have both characters deriving from a parent SideScrollerPerson so that I only have to make the baseline movement components once. I have the movement code in the parent class and both the children just inherit it naturally. This is what’s known as inheritance, a principal of object oriented programming, so it’s more good practice than 100% necessary, you could have them as different classes altogether if you wanted. This style is agnostic so you could do either, I just do it this way.
    image

  2. Are you using only 1 gamepad? Also forgot to mention you need to spawn the local player controller in your gamemode regardless. To test you either have to have 2 or to make a big workaround to having player 0 be the only gamepad As even with the project setting that’s supposed to skip assigning a gamepad to player 0, it still does. So the first keyboard and first gamepad will always only pass inputs to player 0. The 2nd gamepad would then pass inputs to player 1. This is an engine issue in that we don’t have many native tools (unless you use external plugins or build from source) to altering the gamepad system on the backend. I didn’t want to muddy your learning with a bunch of C++ and different plugins to accomplish this.

  1. The only thing I had changed other than the two settings above is making the default pawn a “PressAnyKeyToPlay” pawn, but that doesn’t apply to the simple way above, only for drop in drop out style of play.

@SupportiveEntity

Sorry I haven’t responded in ages! I’ve been absolutely swamped with Uni work, so I’ve had no time for this personal project!!

I haven’t been able to implement what you’ve suggested yet- but I’ll let you know as soon as I can! Just wanted to explain the radio silence quickly ^^

I do have a query in the meantime though- if I’m using the method where both characters are already in the scene, will I still be able to make a death/respawn system? Or will I have to use the other method?

Thanks for everything, and sorry that it took me so long to respond!!

No worries! I’m here most days of the week and here to help you!

Either way you’ll have to do a bit of work on the death/respawn logic. Whenever you have multiplayer in any capacity the baseline unreal spawn player at player starts don’t cut it. While it still works, it’s preferable to run your own. You’re going to want to have control over everything in there. Basically with drop in drop out, you’ll have to maintain a way of spawning another player during gameplay. So spawning them on top of the other player, checkpoints, etc. Same with just having them in the scene really, but you don’t really have to worry about spawning a player mid game, so it’s only handling the death/respawn. Most cases you don’t even have to destroy the actors, usually good to just move them and reset variables etc.

1 Like