How to Place Builds with a Preview in Unreal Engine 5

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up guys welcome to New UMO Engine 5 tutorial today I am going to show you how to place a build with a preview and everything it's going to be a very easy be to follow so let's get started all right so the first thing I need to do is open up the ctive blueprint in my case I am going to be using the third person character blueprint so let's go to the third person folder Blueprints and open up third person character all right so first of all before even starting with the tutorial what I am going to do is just move slightly the camera to the right so it's easier for us to kind of uh go ahead and and see what we're trying to place right it's a good practice so let's go to camera boom and on the socket offside we're can add some in the y axis for example 35 as you can see the camera has moved to the right and now basically we have a bit of you know of a view to place things which is pretty nice all right so now what we need to do is basically add some line traces which are basically some invisible lines called right casts that we go from one point to another in this case from the camera angle just forward until what we impact and that's where we're going to go ahead and place our build preview so let's go and just create a new function in our third person character blueprint whatever blue you're using and let's just name this something as line trace and on here the first thing that we need to do is add this line Trace by Channel node and this is the node that will basically create our line Trace as you can see it takes two inputs that are very important which are the start and end so for the start point it would to get the uh camera and just get the weld location okay and just plug that there and then for the end point what we want the C forward Vector of the camera so we can know you know when uh which direction we are looking we can also just do the same by just getting the W rotation and then the get forward Vector it's basically the same so you know you can choose if you want to do it directly or with rotation and now what we need to do is just times this by a value and this will be the distance okay how much it will go forward so let's right click convert this to a float so it can be a nice number and let's put for example 500 so we can build 500 units forward and until that is where we can build and then you know more far away from that we can't and then we only need to add these two vectors together and we get the end point so we set the draw thebook type for duration as you can see uh we will not see anything because uh we are not this line train function so let's go to event graph add an event tick and put it on there so why are we doing it on the event tick well that's because on every frame constantly we are going to be calculating this so let me go ahead and extract the line trades function that we just created and then with that I can just go press play and boom we have it on here as you can see it's going and impacting the ground right well actually it doesn't reach the ground so it has to be even a bit more than 500 maybe let's put something as 1,000 just to make sure and now it was you can see that it would go spad away and actually makes that little red spot on the ground which means that we have impacted so basically there is where we're going to go ahead and just place our preview of our build so let's create some outputs in this case the outputs can be created by you know just clicking on the function adding an output and the first output will be the location so where is the location that we want to build on and then also the rotation you know and with that said now we can just go and pass in a vector and here we can put a rotator so let's just go and put this here but we need to access that uh information how do we do it well first of all we need to make sure that we have collided with something so let's make a branch on the return value and if it's true we will go ahead and continue here and now we need to go ahead and get this uh outad and just break it and with this we get all the parameters about the information that we have just collided with so in this case the location will be location and the rotation this if you want to kind of build object uh coming from the surface so we can just get the normal make a rotation from X and then we can get the return value to the rotation so basically all the objects will be popping up from the surface okay where is it pointing at so you can use that rotation if you want or not and then for false you're going to copy and paste this node and just place over here so it will set everything to zero Z and we will not see that build okay because we have not detected a surface and with that said now we get two outputs which is pretty cool but we will not use them right now the first thing that we need to do is go to the begin play which is when the game starts and add a new component so let's just go ah here and do component by class there we go add component by class and what component will be it will be a static mesh component okay so this will be the preview that will be created and we will do it as component because it will be very easy for us to add it and then remove it later on I would need to create a whole actor for that all right now what relative transform will this have but for now let me just go ahead and just uh use the make a transform node and I'm going to just place it on the 00 Z just for now because later we will update this but now the important thing will be setting the static mesh of this object which is what object want to place in this case I'm going to be using a uh let me use a table right there we go and then also we're going to go ahead and set a new material okay we'll do that a bit later so I can showcase how this looks but basically right now we are creating a new component on the z0 of our character as you can see which it looks pretty funny now we just need to update that transform so we're going to go ahead and save this mesh component as a variable so let's right click promote variable this will be something as a build preview mesh all right place it over here and there we go so now it is saved there as a variable so now on the event tick we can go ahead and use it so let's drag it get it right click and use say convert to validated G so it will only continue if this has been created and we're doing this later on so when we remove that it basically goes ahead and disappears but basically now we just need to set the W transform of this object okay make sure it's well transform with this new location and rotation so let's right click on the transform and split it and now we have the individual things as location and rotation and now if I press place you can see the uh table will basically appear there and this was what I was saying about the aligning to the surface if you want to use the rotation you can like that but in this case I'm going to disable the rotation so I always get the same rotation uh whenever I'm looking and it doesn't align to walls but you can choose that if you want anyways you can see now it is working so first of all let's go and disable the line Trace preview as you can see let's put it to nonone and then also we will go ahead and apply any new material so let's create a preview material will be something as transparent and kind of you know bluish greenish whatever you want to put so let right click new material mcore preview uh something as a build preview I think will be a bit better preview mes let's open this up and then we can just go and hold three on our keyboard and just left click and this creates a new color uh node let's double click and put a color I think I like this kind of Pinky one and then let's just hold one left click and plug it into the uh opacity which is not available so let's select this on our graph to go to the main details of the material and we can put the blend mode to translucent and now it will be transparent and we can put something as 0.5 of opacity so will be a bit transparent we can close this go back to here when we add that and just set the material let's move the build mesh bit later boom boom boom boom and this material will be of course the preview that we have just created uh which is here and now when I go here as you can see boom we have this preview material going on which looks pretty cool now of course we cannot still Place anything so we need to make sure to do that so let's go down just create a new input so let's go to third person input actions right click input action I aore place build let's add it to the collection so we can go ahead and assign a key so this will be Place build expand this and just click on this icon and then press the left Mouse button or whatever key you want now let right click and do a i aore Place build and now expand to this and only started so when we start pressing the mouse button we will go ahead and place the build so we're going to make it simple just do a spawn actor from class and then you select what actor you want in this case let's right click create a new blueprint class actor BP [Music] build and let's now just go ahead and add a static mesh to this build which will be the mesh itself and by default I'm going to be adding that table that I'm using and now I can just select that uh build blueprint and specify where which in this case will be exactly on our location that we are choosing so let's split it and we're going to go ahead and use right click promote this to a variable this will be build Place location and I will just save this right after and get it from here and boom and everything by default and let's make this always spawn in not C so we will make sure that our build will always spawn even though it's kind of a you know tiny space we don't care about that and now as you can see we can see the preview and boom we can go ahead and place builds which is pretty cool so that's it guys found this video helpful I would really appreciate it you can like video And subscribe to my channel I lots of uni videos and th so check them out remember I have full access to the prep files through patreon or YouTube members so Link in the description join my Discord server to follow me and um you know other Game Dev in this amazing F journey and follow me on my socials and now yes with all said [Music] bye-bye
Info
Channel: Gorka Games
Views: 6,330
Rating: undefined out of 5
Keywords: games, videojuegos, unreal engine, unreal engine 5, ue5 place builds, tutorial, quixel, megascans, unreal engine build, building in unreal engine 5, ue5 place build with preview, place actors in realtime tutorial, place build, unreal engine 5 how to build actors, unreal engine 5 place build object, unreal engine 5 build object
Id: b88Dj_k9b84
Channel Id: undefined
Length: 10min 59sec (659 seconds)
Published: Sun Mar 10 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.