2019 Ultimate Unreal C++ Guide - Episode 1

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello everyone after a one-year break from making videos it's time for me to come back and make more unfinished series I had this awesome idea that I'd imposed my face onto a sphere unfortunately this angle really doesn't flatter me and I swear I am more handsome usually well my other unfinished C++ series is around a year old now and with Unreal Engine constantly changing it's time for a brand new ultimate Unreal Engine C++ series join me as your host and let me teach you a thing or two about how to make games with own religion right after these messages from a sponsor who was actually me learn to make a fully working better real game you can play with friends using my udemy course try for $13.99 using the link in the description because Unreal Engine can get confusing and make as little sense as this pig with smoke coming out of it I'm going to explain the absolute basics first and then we can try to tackle some of the coding shortly let's start with actors and actor as any object inside the level like this pig here or this wolf or this pole or the streetlamp or this other pole or this other pole or these crows the interesting thing about actors however is that they made up of actor components for example if I click on the pig here you can see that there's one part of the pig that's the part we can see and that's a skeletal mesh component and then there's also a particle system that's the smoke part of the pig so anything you need to make inside of Unreal Engine you'll generally make it by creating an actor and then adding whatever actor components you need to it to further explain this concept let's take a look at my character here now in the game here's my character and I can move them around using the WASD keys but if we actually take a look at the actor there's a ton of components that make him up for example there's a capsule component to provide collision and make sure our character doesn't walk through walls there's an arrow component to show which way is forward there's a mesh component which is the part of the character you can acts leacy there's a camera boom which is what the camera attaches to there's a camera which represents our point of view and then finally there's a character movement component to drive our character's movement and the idea is and I really can't stress this enough anything that you want to make within the Unreal Engine can basically be made of an actor and then just adding a series of different components to it it's no secret the making games is really hard and while I'd love to show you how to install Visual Studio I feel like if you don't understand how to install Visual Studio then this course is probably gonna be beyond what you're capable of doing anyway so that's your first challenge and still Unreal Engine on your own but I will leave a link in the description to a guide so it really shouldn't be that hard keep in mind with us being a C++ series as well you will need Visual Studio installed I am using Unreal Engine version 4.2 one for this series and although 4.22 will be out soon we're not going to be using out because it's still in previous and make sure that you use 4.21 that is very important otherwise you might have some slight issues going forward when you click on launch to launch the Unreal Engine you'll be greeted with the project browser here in the project browser you can click on the new project tab go to C++ and we're going to make a new third-person template project I like to use the third-person template because it gives us a nice character that we can walk around with and you can go ahead and call this whatever you want I'm just gonna call it ultimate once you click create project it will generate all of the code files and do all of the other project creation related stuff if you installed everything quickly you will have a Unreal project window open and you'll also have Visual Studio open as well but we'll get to that in a little bit so let's just quickly show you around the Unreal Engine and take you through some of the things the first thing that you'll see is going to be the modes panel this has a bunch of things you can drag into the level and honestly we really don't need to worry about it right now this is the toolbar there's a bunch of options like sittings playing the game at cetera the world outliner is a big list of every actor in the world so if we click on for example the player which is an actor you can see it appears here in the list the details panel shows you the details for an actor that you've selected it'll show you all of the components in that actor and if you click on a component you can see the details for that component as well you also have the content browser this is similar to if you've use something like unity it just has all of the folders for your project and all of the assets as well so that's the basic tools to move around hold the right mouse button down to rotate hold the left mouse button down and move your mouse to move around and scrolling will sort of zoom the the camera backwards and forwards like that so you can you can get around pretty easily like that so we're gonna click play and as you can see we can now run around with our character let's go ahead and we'll write our first little bit of code it's going to be super simple we're just going to make our own custom actor so when the modes panel up here you can see that if I drag an empty actor into the level I can click Add component and I can add things like Mischa's if I would like to I could add a let's see here I could add whatever I want I could add a sphere so you can add a blank actor and add different components to it and that's really all that our character is right it's a blank actor but then we just add a bunch of components to it so to make a new custom actor you do this all through the c++ side of things we're gonna click on file new c++ class and then click on actor next we'll need to give our actor a name I'm going to go here and call mine custom actor so if you've installed everything correctly in Visual Studio it will open up your project I'm using a plug-in called visual assist so all of my characters are a different color but if you're doing a visual assist it's really not a big deal what I'm going to do is I'm going to create a actor so you can see here is Mike acta class and I'm just gonna add a really simple component that's all I'm gonna do is just add one component to my actor and and that's really all we need to do for now to create components you do this inside of the constructor of your class you can see this method here is the constructor now if you've done this a plus plus c-sharp etc you will know what a constructor is and I do require that you at least know some basic coding to partake in the series of course you could not know how to code and copy along but you really wouldn't be understanding much it's up to you anyways we're going to go to custom actor dot CPP I'm going to go to the constructor and let's add our first component to add a component to the actor you simply just type create default sub object and this is a function that will create a sub object now a sub object is owned by our actor and it can be components and it can be other things but generally speaking this is how we create components and add them to an actor now this function has a template so you do need to do these angled brackets here and then put the type that we're trying to create I'm going to add a static mesh component to my actor so we're going to type you static mesh component and then inside of here and quotes we're gonna put the name of the component once we've done that we're just gonna put a semicolon at the end and that is literally all you need to create a static mesh it's very very simple however this really doesn't make sense because why would we go to the effort of coding our own custom actor if it didn't do anything special in unreal engine you can simply drag a empty actor into the level and then just add component inside of the editor so why would we go to all this effort of coding a custom solution for this so let's add a little bit of custom code and make this act to do something special that it wouldn't normally be able to do I'm going to make this actor a random size so the size of the actor will be completely random when it begins playing what we need is we need a variable to store a static mesh component and that we just created so you can create a static mesh component but you do need a variable to store that in let's go back to custom actor H and we'll make under the protected section a new you static mesh component this does need to be a pointer and we're going to call this static mesh in Unreal Engine 4 we have these things called decorators and these allow you to describe two different information about variables to Unreal Engine one of them is called new properties so above the use static mesh component we're going to type you property this is a macro and what happens is something called the unreal header tool scans over our project and looks for these tags and then it allows us to do different things with this mesh component inside of the engine I'm going to add the meter keyword edit anywhere and I'll also give it a category I'm gonna call it components so for now although this property thing might be a little bit confusing this will start to make more sense as we use them more and more you will use these everywhere they are very very common and what putting edit anywhere will do is it will allow us to edit this component from within Unreal Engine so we're gonna go ahead and go back into custom actor and we'll say that static mesh is equal to this default sub object and then when we start the game I'm going to set the scale of the static mesh to be a random value so you can scale a static mesh and make it bigger or smaller and the way that you do that is you say static mesh set scale 3d and there's set relative scale and set world scale we're gonna use set world scale and you can see there is if Victor knew scale now the little special custom logic that I wanna code into our actor as I want it to be a random scale to get a random scale you can do this really easily in Unreal Engine by typing FF vir and and that will just give you a random victor and then we're sitting that static mesh scale equal to the return type of that victor so that we can use the steding mesh we're going to include the header file for it so we're going to type hash or pound sign and cloade and then inside of brackets we're going to say classes slash components make sure that you use forward slashes and then you want to say static mesh component H this will allow us to actually use the static mesh inside of the engine or inside of this class I should say and we're doing all of this inside of the begin play function which is called when the game begins so that's pretty much all you need to know about that let's go ahead and click on this little play thing here local windows debugger make sure that your engine is closed and then or your project is closed and then click on this and it will restart the engine but with our new custom actor inside of it okay guys so let's have a look here we'll go down to the sources panel click on C++ classes and here is our custom actor that we just made go ahead and drag the custom actor into the level instead of dragging an empty actor and this time we're dragging our own custom actor in click on static mesh click the drop down and I'm gonna search for the cheer in fact it looks like we don't have a cheer let's just click on the cube and we'll go ahead and drag the cube up and when I play the game notice that the cube is a random scale every single time that I play the game so this is how you would make any sort of game thing that you want you just create your own actor and then add some custom logic to it so how cool is that we've made our first actor obviously it doesn't do a lot right now it just sits itself to a random scale but nonetheless it's a nice starting point and it's a basic example to show you guys how actors work so in the next video I think we're gonna get a little bit more complicated than just doing this but I think that's a pretty good starting point so now I would just get familiar with navigating around the Unreal editor and just figuring out what all the different buttons do and things like that anyways I'll see you guys in the next tutorial
Info
Channel: reubs
Views: 198,830
Rating: undefined out of 5
Keywords: Unreal, Engine, C++, Tutorial, Beginner, Game, Programming
Id: 3JpNil0_gm4
Channel Id: undefined
Length: 14min 6sec (846 seconds)
Published: Mon Feb 25 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.