How to Use C++ in Unreal Engine 5 - Beginner Tutorial

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 gonna show you on how to get started with three plus plus in Unreal Engine 5. it's gonna be a very easy video to follow so let's get started but first check out the link in the description to get out with some unreal ending courses on winfox alright so first of all let's go ahead and create a new C plus plus price so uh today I'm gonna be using the 5.1 so if you want to use the same ongoing version you of course can of course you can use another premium Engine 5 version like 5.03 5.02 but I recommend using later one which is 5.1 anyway we're gonna go ahead and create a new um third person uh template it's gonna be on C plus plus remember that and we're going to leave everything as default with the starter content and stuff and then we can just plug the name it's gonna be like C plus plus um underscore tutorial okay and now let's go ahead and create this uh product okay so now that the product is open you will see that the Unreal Engine editor has opened and also we have Visual Studio Community which is just uh also opened with the pride so let's guess now started now there's a thing that I want to clarify and first of all um before we start so a lot of people has this question is you know they have to completely make the game in two plus plus or in Blueprint well there's a simple answer to that you have to basically use the combination of both C plus plus and blueprints in order to create the most efficient systems and workflow for a game basically you will have to use both okay and you will need to code some systems in position and C plus plus and then you'll basically call them in your Blueprints and Etc so it's hard at the start snow you know in which system you have to make in these purpose and which system you have to make blueprints but as you go I make more things it will be easier for you but anyway let's continue with the tutorial now that we have clarified that so now to create a new uh C plus plus class what you do is go into tools new C plus class now we have different templates and we can use for example the same as if we were to create a new blueprint class so my guess I'm going to choose a character I'm going to say next and then I'm going to just put a name now for me I would just say for example let's say a tutorial character okay we can leave everything as default we're not going to touch anything and just say uh generate class and there we go uh you know Visual Studio will go ahead and open of course you have to have installed vessels to the community with the latest version with the T bus plus uh code implemented Etc now I think that I want to also clarify about um this tutorial is that this this is not a C plus plus tutorial I will not be teaching that this is just a way to implement C plus plus into Unreal Engine and you know do a simple example of just spawning an actor in the scene on C plus plus calling it from blueprint so this is not a C plus plus coding tutorial no this is very simple this is just of how to make a simple system in simple Sports and integrated into blueprints so you know a better how the implementation works so first of all you will see that we have two files we have a c plus file and we have a header file now the C plus plus file will be basically where we actually Implement of the code of the functions and the variables basically all the functionality and the header file is where we're gonna go ahead and create and declare all the functions and variables so in this example the tutorial we're going to do is basically then when you press a key it will spawn a certain actor just in front of the character uh we do in all the functionality from Super Sports and then call it from blueprints later on so the first thing I want to do is go ahead and create a new function so for this we're going to go into the header as is the place that we create and declare functions of variables I'm going to go into the public section over here and go down and then we're going to say void and then we can just call this as we want so my case will be like spawn actor okay go ahead and there we go now the things that we have to put a certain um tag um on top of all our variables and functions in Unreal Engine so this will be a new function and then we can open and we can have different options now in our case we want to be able to call this function from blueprint so in our case we just pass the parameter of blueprint callable now you may have noticed that it isn't out to completing um all the the names and stuff this because the visual studio into sense doesn't really work correctly with C plus plus and Unreal Engine so what you have to do is basically um get a plugin that will base basically do all the auto completion to you now I'll be linking two good ones in description that they're used by all Professionals in the Unreal Engine C plus plus community and basically it will help you a lot now they have a free trial and then you'll have to pay them but they're really good if you want to get serious about C plus in Unreal Engine anyway to today I'm just gonna do without any auto completion but it's okay because your means are going to be explaining everything so now we can pass in a second parameter which is going to be basically category so we can have things more organized when later on we call them from the blueprints and it's going to be for example abilities as I guess like you can have like a superpower it's gonna be like spawning actor you know I don't know whatever you can put whatever name you want and I guess gonna be good and I invented this is nice and organized and there we go we can now go ahead and save this file so now now we're going to go into the C plus plus file and actually Implement all of this code so we're gonna go down over here and we're going to do is say void and now we have to pass the class name which in my case was tutorial character it's kind of character there we go and now the thing is that we have to pass an A in front of the class name in order to symbolize which is an actor and then we have to do it so uh doubles if we call and then say spawn actor which is basically the name all four functions so basically to reference the actor class name it's with an a at the front and then the uh function name and then you can put this and then open the keys and then we can now start typing inside of it and putting all the functionality so in this example like I mentioned before I want to be able to spawn any actor in a certain position when I press a key so I'm going to do is I get Weld and now this is going to be a very handy um place to get a lot of things and all the functionality in Unreal Engine so it we have this spawn actor and then we can just pass the type which we want which in a case will be an a actor okay now close this sorry about the C over here there you go a actor and then we can open parenthesis and pass all the parameters that we need so in our case we have to pass first of all and a specific the specific blueprint or actor that we want to spawn now for this we're going to do is create another variable so I'm going to go back into the header class and go down over here and we're going to create a new variable now what we can do is just say a actor and then put here actor BP to spawn for example name it like this now the thing is that um Unreal Engine uh and C plus plus doesn't really recognize very well like uh the content browser um files and basically all the blueprints connectors that they're there so we have to do is pass another um here and the parameter will be a subclass off open keys and then close these and then this will be a t sub class sorry the video of a actor and then we pass the name now we have to do one more thing which is pass another uh tag on top of it so in a function was basically you function button here is you property let's go ahead and pass this and I will go ahead and open the parameters and now we can plus uh sorry plugin uh another thing which is edit anywhere so this will basically allow us to you just call it from whatever place we want in our blueprint I'm gonna go ahead and then this so it's nice and organized we can just save it so now we can go ahead and call this uh actor BB to spawn from our um or code so now it's basically spawn that variable and now what we can do is just pass a transform basically a location or a position that we want our actors to spawn so in our case we're going to say is just get actor transform so it will basically spawn it right in our player's face and then we want to do is just pass some parameters so in order to this what we have to do is create some local variables so be F actor uh spawn parameters and it's going to be like these spawn params for example and then we need to set these spawn params to a certain thing so we want to basically change its Collision um settings so it's going to be spawn Collision uh handling override here we go sometimes it is I would completely it's on this node that's why the in two cells with armual engine doesn't really work really well and I'm going to pass the e-spawn actor Collision any method that we go is now Auto completing and now we can have different options so adjust if possible but I will spawn Etc always spawn Instagram so in my case I'm gonna say I just possible but always spawn so there we go and we can put a semicolon to add in line and now we can pass the we go the spawn Palms on here there we go now we can go ahead and close this over here now you will see that sometimes it gives errors well this is another problem with C personal real Engine with Intel sense it will sometimes give you errors even though the code is actually correct so don't worry if there's errors sometimes it is an acronym you're using the normal Indian cells on a male engine sorry okay so now we can go ahead and save all of our files and minimize and go back into real ending now you will see that this um window popped up which is the C plus plus light coding now this is just a way to compile very fast in Unreal Engine 5. now just close it and if you don't see that um at all what you can just go back down here and say and click on this and it will basically start compiling all of your code so now you will just wait a few seconds now depending on which drive you have it it will go faster or slower but just have some you know uh space on them and then just wait a few seconds a note that I'm gonna put it on here is that if you only touch the C plus plus file it will actually go faster but if you touch the C the header file it will go slower because it has to compile other headphones and stuff anyway you can see that now it has successfully um compiled without any errors okay so now what we can do is go ahead and um place our character in the scene now there's two ways that we can do this we just go ahead and right click and create a new blueprint class then we can go into all classes and search the class that we created so it will be tutorial character now there will be two uh as the second one over here I don't know why this Pride already had one but anyway I think it just it was a Content example something like that so we can get selected BP underscore tutorial we can now open it up and now you will see that first of all in class Depots we have the variable that we created and now in the band graph we can just right click and go into spawn actor and you will see the under the category abilities as we already said and another way of doing this is that we can actually go ahead and re-parent into another uh you know whatever other character we have over here but I'm going to go ahead and continue so I'm going to say that when we press the left Mouse button we're going to go ahead and spawn our actor under a Bluetooth remember and then we just put over here this and then in the class defaults we can search for whatever actor we want so I'm going to go ahead and quickly just create a new blooping class it's going to be type actor BP Factor okay go ahead and open him I'm just gonna say it's gonna be a simple um Cube which is going to be the scene Boot and it will just have some Physics so we can basically go ahead and unfold we can now close it and now we can just call it from here so we'll basically spawn this actor each time that we uh press it now I'm gonna quickly apply a mesh into this so Queen there we go and then Queen simple and then let me just go ahead and reposition this there we go okay now I press play and we'll still need a camera sorry so quickly go here add a camera there we go and then a a boom camera boom oh they changed the name right it's no longer countable it's a spring arm there you go this will be the other way around it can all be child Springer and there we go okay so now we have a character here uh oh we have to also set in here so we have to create a new game mode quickly just do this so flipping class uh game mode GM for example open it up so the default Palm class it will be BP tutorial upon close it we can go back into what settings it's going to be GM now if I press play there we go we have our characters now if I were to I'll left click you'll see that we have D spawn the the cube actually spawning really cool guys we are actually spawning from uh C plus plus which is really really cool I'm gonna go ahead and just change this a bit okay so we can basically see a bit better um okay here we go I know that I don't have the controls but anyway you can see how when I left click it's actually spawning the uh D cubes and stuff in his position so you can see in the C plus plus we're doing exactly that we are spawning the variable that is set on the blueprint in a certain transform that will be basically this transfer the get actor would transform and then we have the parameters over here which is just um things that were will be automatically done in blueprints we have to also build them in C plus plus because well it's just how it is now for example we could make a new variable for the actor transform so let's quickly do that we can go into the header and just copy the edit anywhere tag and then we just go here and just create an f um transform and then it's going to be I don't know spawn pause for example and then we're going to save this and go into DC plus we can just change this into spawn pause and then save it and then go back into real now we can go ahead and click this to basically compile all of the code and just wait a few seconds there we go it has completely um successfully compiled of the blueprint so now we can go into the BB tutorial we can go into class defaults and you will see the transform variable over here so now we can basically apply it into whatever we want so for example we're going to say it's gonna be on the uh zero zero zero the world but on like 50 of height go ahead and spawn so you can see that it's actually creating new actors over here they spawn them but they're being destroyed immediately I think that they're too high or something like that um let's put like 10 and then I don't know which position is for example this say for example a thousand uh and 200 sorry 120 not 100 200 and then a thousand and four hundred and then ten of up okay so now it should spawn around there there we go we're gonna say the cubes being uh spawned over here so that's extremely cool as you can see um so yeah you can basically play with the settings and do whatever you want so I'm gonna be wrapping this video up this just was a quick introduction to C plus plus and how you can integrate them into Blueprints and into unview engine 5. if you enjoyed the video and found it helpful I really appreciate if you collect the video and subscribe to my channel I have lots of Unreal Engine 5 tutorials for this one so I just go ahead and check them out with all that said if you want to see more videos about this um or any other videos let me know in the comments I know yes we're all said bye bye foreign [Music]
Info
Channel: Gorka Games
Views: 182,884
Rating: undefined out of 5
Keywords: games, videojuegos, unreal engine, unreal engine 5, ue5, c++, tutorial, quixel, megascans, unreal engine c++, c plus plus unreal engine 5, ue5 how to use c++, ue5 c++ tutorial, ue5 how to make a game with c++, unreal engine 5 simple blueprint for c++, unreal engine 5 easy c plus plus, unreal engine 5 c++ beginner, unreal engine 5 how to make a script, unreal engine 4, ue4, unreal engine 5 easy c++ tutorial, ue5 simple c plus plus tutorial, blueprints in c++ in ue5
Id: HNfpKFER2hI
Channel Id: undefined
Length: 17min 39sec (1059 seconds)
Published: Mon Dec 26 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.