How to Swap Character when pressing a Button in Unreal Engine 5

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up guys welcome to new unreal engine 5 tutorial and today i'm going to show you only how to swap or change characters in the game so you're playing as a character and you press a button and then you change to another character that is in the scene it's going to be a very easy video to follow so let's get started all right so the first thing that we are going to do is go into a third person blueprints okay so now what we have to do is go into the um third person character okay and what you're going to do is just change the color of the mannequin and depending if we are one or another one okay so you know for example um i can just create a variable here which is going to be um player one okay it's gonna be a boolean so now i can go into the construction script and this will just update also not in real and runtime but also like in the editor and basically i'm just gonna drag this and say get okay also i'm gonna get the player one variable and make it a public so i can access it later then just drag this make a branch and if this is uh false so if it's the other player i'm just gonna change the uh mesh so set material and then you just put it in here um it's gonna be the number two uh because i want to change the second material on here um which actually i would say is is one uh yes actually one because it's from zero to one yeah and then on here um i have a mannequin material so it is a queen um so i've created before and it's just queen three okay so it looks a bit different okay all right so now an important thing is that right now when we press you know play we basically uh spawn the character into um well the player spell that we have on our scene or or what the camera is right because of the game mode okay uh right now it's just picking up this color uh because basically it's not true but if i were to put this uh through you will see that now i would be the normal uh metahuman so you know now it's working so yeah i'm gonna leave it up by default on true and then what we're going to do is just uh go into the world settings and basically in game mode selected game mode what we're going to do is in default uh the default pound class sorry instead of selecting the third person character what we're going to do is click none so it will not spawn a character right now so what we're going to do now is just get our third person character drag it into the scene okay here we go so this will be for example player one so i can go into details and then uh you will see that i have here the variable and that we created which is player one so yeah this will be player one and there's a thing to basically uh be able to control it if you scroll a bit down you'll see pound and then we have an auto process player instead of disabled it's gonna be player zero okay so now what we can do you just duplicate this character in the scene and uh when it loads i will be able to you know position it uh whenever i want so i can just drag it let's see if it loads this is a bit slow my computer because i'm recording and stuff i can just rotate it so we can later see how you know it would look and then what i can do it just in this one um in the variables i can just set player 1 to false so we'll change to green and also i'm just going to put the outside process player back to disabled okay let me go ahead and press play you will see that we are the the player one which is this one okay so now we want to switch between this one and that one so for that we need to open the level blueprint because we need some references into uh both characters so we go here and then you're gonna say open level blueprint and this will basically open up a level blueprint okay i have you know some things here from another tutorial but it doesn't really matter um it won't affect us at all all right so just it will be pretty much like this with that maybe a big gameplay or whatever we don't need anything so you can just go into an empty space all right so now that we have just a blank space um we are gonna reference our two players so we can just go into the third person map and we'll let's start with the flash first place so you select the first player then just hopping back into the third person map blueprint level is right click and we have a button to create a reference to that character so we're going to click it let's go back in third person map and do the same with the other one so you select this one go back into the level blueprint right click and create a reference great so now we have two references so now let's go ahead and when we press a key we'll basically switch between them so to do it properly i'm just going to go into edit press settings and the difference is that if we do uh you know the setup the input from the price settings we have so much more control we can assign different like keys for that um a specific one we can also say to be the gamepad etc okay so we can just go into input here in action is uh add a new action mapping we go open it and now let's call this switch um player how we're going to call that now we can just press this keyboard key and then for example and press tab okay and then when we you know press tab this will happen you can also set it up for the gamepad but anyway now we can close it and just say switch player and this is the new input action so in press we're going to do is a flip flop and basically the flip flop means that one time it will do a another time we do b so because we'll be starting with the player one in the when we call the first time it will be to switch to 32 so in the a is gonna be two player two so we just want to get our third person character two drag it and possess sorry and just uh first of all we need to get the reference to get player controller and now we can um process we go process so we can just put it into a sear it's up here okay and now that's the target but the impound will be the two and then let's go ahead and copy this paste in here and then b it's gonna be instead of um two it's gonna be the first one okay so we can just put it on here all right so now we were to compile and save go back into our level if we press play i'm the first player you can see but if i press tab you can see that right now i'm the second player so now if i press tab again i go back into my first player and it's really cool you can make a whole game which basically uses the logic that you have to change players to get along levels or whatever so yeah guys if you enjoyed the video and found it helpful please i would really appreciate it if you could like the video and subscribe i have lots of unreal engine 5 tutorials in my channel so you want to check it out go ahead also you have any videos you want to see let me know and just leave a comment down below so now yes with all that said bye bye [Music] you
Info
Channel: Gorka Games
Views: 17,796
Rating: undefined out of 5
Keywords: games, videojuegos, unreal engine, unreal engine 5, ue5, swap character, tutorial, quixel, megascans, unreal engine tutorial, change character, ue5 swap character, ue5 change character, ue5 swap player tutorial, unreal engine change player, unreal engine 5 swap player, unreal engine 5 change player, unreal engine swap character in level, unreal engine 4, ue4, unreal engine 5 swap between players, ue5 tutorial change between characters, how to swap characters in ue5
Id: 3aLBUDlrids
Channel Id: undefined
Length: 7min 5sec (425 seconds)
Published: Wed Sep 14 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.