Character Selection Screen - #30 Creating A Role Playing Game With Unreal Engine 4

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] good afternoon ladies and gentlemen you boy virtus here and welcome back to the Unreal Engine 4 RPG series in today's video we are going to be taking a quick look at how we can set up a simple class selection screen for our game now as of right now we've got two characters first things first we've got the magic character and we've also got the sword character now we want the player to be able to choose which one of these characters it's going to load at the start of the game it's really simple and really easy to do so let's go ahead and show you exactly how we can do it so first things first you want to go over to your world settings the reason why we need to do this is because we don't want it to spawn the default pawn class which is currently set to the sword character now if you want to get to world turns just go to edit sorry go to window and then just go to world settings and it'll pop up here on the right hand side change your default pawn class to none and then once you've done this it's just going to stop spawning you into a character and it's going to look like they're spawning you under the world essentially well when I say under the world what it's doing is essentially spawning you in the zero zero zero location in your level now we can change the spawn location for our character and also for where the character selection is going to be but there's something that we'll do in a little bit so now that we've done this what we need to do is set up a blueprint widget that's going to contain the buttons for the player to be able to choose their class so go to user interface and then go to widget blueprint from the content browser and just give this the name class underscore select it doesn't really matter what you call it just give it a name that you'll recognize and then just open this up give it a couple of seconds to load and then once we're in here where we are going to add two buttons and we're gonna track these on the left hand side so the player knows they've got a selection and with these buttons we're also going to add some text as well just so the player knows what each of these buttons are going to do so I'm going to select my top piece of text up here and I'm just going to set the text for this to Magic character and then for the second one I am going to set this to sort character and then just stretch this textbox out so it can fit over text in and I'm also going to make my boxes a little bit bigger just like that now what I'm also going to do with my buttons is quickly copy this size for X&Y and paste it onto the other one just so they match in terms of size just so it looks you know half decent anyway now that we've got this let's move on to the functionality of these buttons and how we're actually going to spawn the actors within our scene when I say the actors I mean the player cab blueprint so let me show you exactly what we're going to be spawning into the scene so we've got these two blueprints magic character and sword character and these contain all of the information for the player the movement the mesh the animations and all of that good stuff now the default pawn class is set to none so we pretty much need to after the game has started tell it to spawn this character and possess it so the way we're gonna do this is by opening this widget back up choose the first button and then from this we are gonna create an on collect event for when they press the button so here we are on pressed or unclick Travie and then with this first things first we're going to tell it to spawn an actor from class to start with and then from this we need to find the actor the actor for this one being the top one it's the magic character blueprint we want to spawn so class click the little drop down and just type in magic underscore character or whatever you've named it to and then from this what we're gonna do is drag this off to an is valid note just to make sure everything's all good and then on is valid what we're gonna do is use the possess node now to get access to this possess node we need to get the player controller is that's going to handle all the information for jumping between you know the different axes one of the characters rather so just drag out from get player controller and just type in possess just like that and then just chuck this into is valid target is get player controller in porn it's going to be the one that we've just spawned and then also for that is valid node just hook this up as well to your return value for the magic character now the next bit that we need to do is the spawn transform which is essentially our way of telling the engine where to spawn that character so I'm going to drag out from spawn transform and simply type in make transform now what we're going to do with this is we are just going to predetermine a location for this stuff to be spawned into now the way we're going to get this location is quite simple so there should be a player starting here somewhere so if I click the place our in start in my scene outliner or just select anywhere in my scene go to details and then if I just drag this up a bit I can get the location relative to my map right here so I'm going to get the X just ctrl C to copy that and then with this I'm going to jump back in here paste it in some - 970 make sure we get rid of a centimeters as well I don't know why that's there and then also get your Y so just paste that in once again make sure you get rid of a centimeters and then one more just get this erred as well and just paste it in just like that and that is going to spawn our character when we press this button in the location of you know that player start that we've got and that's all good so what we need to do now then is pretty much just copy this all of it apart from the on clicked event and do the same thing but for the sword character so over here in your spawn actor just change this to sword character and then go back to your design view and just create another on clicked event for the sword character so on clicked bring this up here and then just make it feed into this and we are all good now one thing you do want to do with these spawn act and it's being you know player stuff you want to set your collision handling override to always spawn ignore collisions otherwise sometimes when you press it it's just not going to spawn your character the player is not gonna have any control and it's just gonna feel really buggy but it's not what we're after so now that we've done this what we need to do is we need to go ahead and you know display that blueprint on the screen because right now you are essentially just floating in space and it doesn't look that great so let's go ahead and get that displayed on the screen and the way that we're gonna do this for now is just the simplest and the dirtiest way of doing it which is by opening up the level blueprint and then right click and create a begin play event and then with this simply tell it to create a widget and with this just add it to the viewport and then for the class simply set this to class underscore select the widget that we created earlier and now if I compile this press play you can see we've now got the buttons on the left-hand side of the screen and if I go over to these buttons like the magic character I can then click that and it's going to spawn it into my scene and that looks all good now bear in mind we've got a couple of issues you couldn't really see the mouse cursor and also when you press the buttons it's not going to remove the widget from our screen so you've still got our class Alex let's see if we can fix this up for you so open up your class select first of all and then with this go to your graph what we're going to be doing with this once they possess it we are simply going to tell it to remove from parent and what this is going to do is pretty much just take away this widget from the player screen so if I compile this now press play and then hit one of these buttons you're gonna see it disappears and it does exactly what we want it to so the next thing that we need to do then is we need to tell it to show the mouse cursor so the way we're gonna do this is by simply opening up our class select go to graph and then anywhere over here find your begin construct I begin construct even we want to cast to the player controller is that's what handles our stuff for the mouse cursor with the object being get player controller and then as player controller set show mouse cursor and simply just check this and we should be good and then what we also need to do at the end of these is we actually need to tell it to cast to the player controller again and we need to tell it to stop showing the mouse cursor so as player controller sets show mouse cursor and then just uncheck this this time and once again object wildcard get player character sorry not get player character get player controller rather so it's just Chuck that in there just like that and we just want to copy this so it works for both of these so now hopefully if we compile this and then press play you can see our mouse cursor and that's all good and then with our magic character and sword character we can click on it and then as soon as we go into the game the mouse cursor is gonna disappear and we are all good on that front and now the player has the ability to choose which you know character they gonna be use and you can really start to see our RPG game come to life now one other thing you might want to look at is that when you press play it's going to go to your default location which is 0 0 0 on the effector location sort of thing anyway so what we're gonna do is because it's under the map I'm just gonna give you a simple solution for that right now which is simply select all and then it's gonna move everything down don't worry it's not going to cause any issues with your level press play and they're gonna sport and it's gonna spawn you in a better location so I still think it needs to go over a little bit so I'm going to push it backwards because you're sort of in-between all the assets so I'm gonna move it backwards down a tad just like that and we're all good and then from here magic character sword character we're all good we can start throwing some projectiles and we can enjoy the game that we made anyway guys that is pretty much everything for today's video once again guys thanks for watching stay awesome keep your a ting your boy Vitus signing out this video was made possible by my supporters on patreon if you want more videos like this check out my patreon page use the link in the description to stay up to date on new releases make sure you follow us on social media
Info
Channel: DevSquad
Views: 44,617
Rating: undefined out of 5
Keywords: Unreal Engine 4, UE4, First Person, unreal engine, VirtusEdu, Virtus Learning Hub, Game Dev, Game Design, Beginner, Blueprints, Unreal Engine Tutorial, RPG Tutorial Series, RPG, RPG Tutorial, RPG Game, How to make an RPG Game, Unreal Engine 4 RPG Tutorial, Project Setup, Episode, Video, Character, Custom Character, Blueprint, Character Selection, Class Select, Characters, Players
Id: axKnZxyNSp8
Channel Id: undefined
Length: 11min 22sec (682 seconds)
Published: Thu Oct 12 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.