VR with Unreal Engine 5 - 2023 Full Intermediate Course

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello hello hello and welcome welcome to Unreal Engine 5 VR course that's aimed for Architects this is an intermediate level course in which I'll try to cover three things that will be showcased right now [Music] [Music] thank you [Music] [Music] foreign [Music] [Music] [Music] [Music] thank you [Music] thank you as you saw after we're done with this video we'll have Sun position control as well as possibilities to switch materials for different objects at runtime which is very very very cool and before we jump into the actual video there is an important thing that I would like to note if you're new to VR development in Unreal Engine please please watch the beginner course first link in the video description below I will be using the scene created in that course to as a kickoff point for this course and by the way that's what you what you actually see now on on the screen right if you want to follow along with exactly the same project the same scene please consider becoming a patreon member as they get all of the files that are done on this channel for free also Link in the video description below and probably pinned comment as well for this being said you don't really need the project files to be able to follow along as the information that is given is going to be quite General and you'll be able to apply it to any project whatsoever okay so let me quickly show you the functionality that we're that we've already built up in the introduction course so that we're all on the same on the same page so here we have a door and we can interact with the door by just kind of shooting shooting at it so we can open and close it and you can see as I as I'm shooting um there is there's a little paw that's added so that that's a functionality so interactive objects right door swing and also another functionality like indirect functionality that was added or maybe not so interactive but dynamic is the the sunlight right so that you can see that the sun actually goes around and and it changes its uh altitude as well it's animated it's non-dynamic so we will need to fix it some things we will keep from the previous project such as the interaction interface between door and our character and others we will completely scrap such as the sun um uh the the send animation and we will replace it with a brand new one so ours will be controlled through the menu right here I mean hours by by hours I mean the sun right so with that being said I think that's enough of an intro for us uh we can right now jump well jump into it okay so here we are in the Unreal Engine project and the thing that we are going to do first is going to be the dynamic material selection of course or not selection but shuffling through a set of materials dynamically at runtime so for that we will need to create a blueprint and we will need to use the same interaction uh workflow or framework that we have already set up in the beginner course right so just quickly to remind you how it works is basically we have our VR template right here blueprints we have our VR Pawn right that's our character basically and we have created these two sets of nodes for the left arm so we have our input action that we have created and once it's started that's sorry that's for the right trigger uh once the input action is started it's going to create a line Trace so basically it's going to shoot out array from the hand right and it's going to check what kind of object is uh does that Ray intersect with right and if the object that is being intersected has this interact blueprint if it calls for this interact blueprint then it's going to trigger right so then if we look at our object that actually has this interactive blueprint for instance our door that we have created there we go let's look at its event graph right we shoot at the door the ray is traced it hits the door this one triggers right this one triggers so it starts the door open or rather it it starts the timeline for door opening and the way the door opens it's basically by rotating um from 0 to 90 degrees if you shoot it again it reverses back right so so it goes goes backwards you can see it from here if door is open then reverse if door is closed then play Then open right so that's how it works and we're basically going to be using the same exact interface framework for interaction between our controller or our character and the materials of any object so in this case I kind of want to do kind of want to work with the floor right I think that that might be quite nice so with the floor selected here in the scene I will create a new blueprint here so we can just do it from from scratch let's do it cleanly right click anywhere on this folder so under Contents I have created blueprints folder that's where all of my blueprints will live and here I'll just right click and choose blueprint class then I choose actor because it's not going to move it's not going to have artificial intelligence anything like that it's gonna be actor right like that and I'll just call it floor that's my floor okay now if I double click it you know it opens up the sector and currently it's empty right it has nothing inside of it so we need to actually add the floor inside of our floor actor how do you do that well first of all let's make this tab a little bit smaller and then let's uh just dock it in somewhere somewhere here maybe go back to our VR template map there we go oh maybe maybe here and basically we need as we have selected the floor here right uh in our outliner the floor B rep has been also selected and that is our static mesh actor right um so I need to find where is it in our content browser to do so all I need to do is just well move my camera away nope that's not how you do it there we go like that uh and so to do so I just click on this little icon right here browse to be rep in content browser bam it finds it for me that's my floor and I just simply drag and drop it in to my default scene or or tune to my component or whatever it's called components tab right here in the actor so now my actor actually has the floor it does not have a material though so let's apply a material to it so now under my floor actor select the B rep here we have the materials for it and I believe I can just do it this way no no I can't okay so I do need to also choose to browse to the material in my content browser like that having two screens is much better when when you're using Unreal Engine and I just drag and drop in my Chevron material here so that's my floor now all neat and dandy all ready to go now let me just compile this and save this and actually let's not close it because there's one more thing that we need to do right that is the positioning we need to figure out where the position of our floor is compared to the scene right in the scene so it's going to be technically you could kind of drag it in and try to match it but it's much better and much more precise if we simply just look at the location values I shouldn't have done that let's go back look at the location values of the floor here right and you just copy this one copy X and paste it here copy y EP and paste it here right so now the location the relative location values are the same right so meaning that if you place this asset or this actor let's go back to it if you place this actor in the scene and make sure that it's placed under under the base model actor this because the base model also has translation information here so let me explain it this way uh our scene is is data Smith a data Smith file right so this is like the main um origin of the scene and you can see that it's moved in X Direction by 990 centimeters right and then everything inside of the main scene has its own you know offset from the origin of the scene right so we need to take our floor here and move it into the base model or whatever it's called in my case it's called base model in your case whatever your data Smith file was called that's going to be the name here so you just drag and drop it in like that floor I believe or maybe you don't maybe no I'm being stupid I'm sorry your first drag and drop it in anywhere in the scene and then once you have it here then you actually drop it into the base model like so well scroll it's going to be a lot of scrolling one second let's make it smaller bomb boom there we go and then you just drag and drop it and it's a little bit annoying I know but hey it is what it is okay so once you've dragged it into base model you have it here floor right then you can delete the old floor that that you had and let's let's find it this one right here we just selected delete yes but now we have a problem why the hell is this floor not here right because our uh the the there we go the location values they are the the ones that we copied and pasted and we added this floor to the base model or or to the main actor of our data Smith scene so why is it just floating about and that is because it's actually the location right here is not zeroed out so what you need to do is you need to select the sector after you've added it to the base model or to your main data Smith actor and you just click on this reset property position so it zeros out and now with its position being zero and it being offseted here actually inside of the actor now it's placed correctly it's a little bit annoying and a little bit awkward with all of the offsets and all of the measurements but trust me once you do it like two times you will figure it out you'll understand it and you won't need to think about it ever again like a lot of work for nothing because we just have this floor here um so we replaced our static mesh with a actor but that's actually a big deal because now in this actor we can create a an event right so go to your uh floor to edit floor go into your actor here let's delete all of the event begin play blah blah we don't need that let's create a new oh wait sorry before we create it we need to go to class defaults or was it class settings sorry it was class to class settings and we need to actually say that this object this floor also calls for the interact interface so it can be interacted with right so where we already have the interact interface done that was done during the beginner course if you don't know what I'm talking about what are you doing here go to the beginner course check it out come back everything will be clear then anyway so under interfaces implemented interfaces we need to add one and here we have interact blueprint that's the one that we've done that's the one that we're using that's done we compile save and now we can see that this interface Channel or not Channel object here is active right so what we can do is we can create an event interact uh uh Advent event interact there we go this one bam and basically from now on if you shoot that little paw at the floor if you shoot a ray at the floor it's this is going to trigger and it's going to do something so what does it do well just give me a second I'll show you all right I prepared my headset here because we'll need to test this out once we're done but but the logic is pretty damn simple all we need to do technically is just one node and that node is called set material set material we already have here brab513 that's our floor B rep or our floor static object we set it up like that we shoot at the ground event triggers connects to set material and for this static object or static mesh right we change its material right so in even graph under material here we can choose whichever we want let me minimize this tab real quick and just drag in the brass into my material slot just like that that's that's the fastest way you can also search for it but I prefer just drag and dropping it with this done that should be yeah we should be good to go actually one thing that I want to do before we start testing things out is I want to remove the animated sun because that just kills the performance and with me recording this video uh the performances necessary I need it so I'll go to our level blueprint right here and here I will just simply under event tick this whole thing where we set actor location for our directional light I'm just going to kill it delete and for event begin play when we set our directional Light sun rotation start like a variable I will remove that and just have this for now even begin play execute console command skill ability 3 or scalability 2. right this will just make sure that um every time when we package this game and we play it uh it runs at high settings rather than epic settings in terms of the performance of quality of the scene not many game graphics cards can handle the Epic settings for VR back to back to here oh this is lagging like crazy now I probably need to restart okay there we go so now it is done it seems like we're back at our 90 frames per second on the viewport that seems good enough and we can try out to see if the ground actually changes with the um this little blueprint that we've made so let's press the play button foreign so it seems like that that does indeed work we press a button it shoots off array it changes the material so now how do you switch through multiple materials well there's only one more node that you need to ask add and it's called multi gate multi-gate right here so every time you trigger this gate it's going to spit out uh the first time you trigger it it's spitting out output number zero second time you trigger it so second time we shoot and second time this is getting triggered it spits out Ctrl C Ctrl V output number one and one more add pin third time we trigger it spits out the output number two there we go all three for the same Europe you can even do it this way uh just use one note to connect all of it together I personally prefer to use separate notes because that is just a little bit cleaner a little bit nicer fun it just I I I want it to be neat and tidy so it is done now we can choose the materials that we actually want to jump between and oh yeah and one more thing if you don't have a loop enabled here this Boolean if this is disabled then it's always going to just go through zero one two and it's going to stop it's not going to kind of go back to zero the fourth time you hit the floor so I will tick mark here Loop is Tick marked so now in terms of the materials okay let's say we that the first time we hit it we switch it to concrete broken concrete floor instead of brass why not second time we hit it we switched to um the the do we do leather no let's not do leather Stone plate no travertine oh we can do marble let's do marble so we do marble and third time we hit it we do uh let's do the same same Oak not Oak Chevron Walnut parquet as what we have originally on our floor so that we can we still have the option to go back right so we have three different materials we just compile we save and that is our floor kind of done time to test it out I guess let me close that let's see if this is going to to work foreign seems to work quite well actually okay awesome so that means we we're good to go this this is working and we are able to switch between different materials now on to On To The Next Step and off camera I will do a few more furniture pieces and so on I will switch material uh make them into switchable actors but basically you know now how to how to do it if you want an actor with multiple different elements yeah you can do so as well it's just that for every single element you will need to specify the XYZ transform you know in in inside of the actor so you basically are will be reassembling this Shelf and as a single actor instance I might do that off camera and besides that uh we are done with the materials we can move on to creating the Sun or to controlling the sun I guess [Music] thank you [Music] [Music] foreign [Music] we're done with one two three four with four of our blueprints that can change materials so just for me to show you how it all looks like let me start the assimilation jump right into it grab that's the wrong arm there we go where's the next one there we go and just if I were to click there there you can see the floor changes and now not just the floor the chair Bam Bam the niche underneath the this wooden Shelf uh if I don't miss it and as well as the walls themselves right let me just position myself somewhere where we can see all three of these let's just go to town um maybe wooden walls concrete or Trevor time floor and then metal there and white on black chair yeah horrible at least the functionality you know at least the functionality works and that's all that matters you can extrapolate from here on what you can do with this and how many kind of different material sets you can um you can choose from or you can assemble just with these four different blueprints okay now we can move on to let me remove or actually before I remove it now we can move on to the sunlight right and controlling the sunlight within our headset while we are so to say playing the game so let me show you again let me jump in right here just grab the controller so the system that we're going to be using is the menu system that's already available let me show you up like that that's already available inside of Unreal Engine right or inside of this template so this system is right now we can restart we can close out the game and we can reset our location back to you back to where it was but we will be adding sliders that control the horizontal placement as well as the vertical placement of our sunlight right at least that's the plan um oh by the way the system is accessible by pressing the menu key on the on the controller if you don't use Oculus Quest 2 then probably there's a different key but there is a key that already gives you the menu anyhow to start controlling the sun first of all we need the sun to be a blueprint rather than a directional light because right now if I go to my environment light mixer you can see that you know we have a directional light and that works as a sun for us uh it's also located right here under lights directional light so instead of this one we need a blueprint I'll go to my content browser I'll go to my blueprints Tab and here I will create a new actor am I okay blueprint class there we go actor and I'll just call it uh Sun BP Sun blueprint it's nvp okay I'll double click on it to open it up and here in this blueprint I will create a directional light so I will click on ADD component and I'll find directional or you can just search directional light there we go let me just add it in um once I've added in it says multiple Direction lines are competing to be the single one used for for chaining translucent water and volumetric fog basically it's saying you you you're trying to create two cents could you not and yes we could not so what we're going to be doing is we'll be deleting our original sun and replacing it with this blueprint that has a directional light in it right before we do that we need to gather the information and kind of transfer the information into this um into the directional Light Within the blueprint so for instance our current sunlight has a specific angle right so we want to copy that and paste it into this so here in the sun blueprint we select the directional light and for it we paste the X rotation copy y rotation and copy that rotation there we go the scale doesn't matter so you don't need to worry about that the light needs to be movable and it is right and you need the intensity as well as well actually let me show you a trick you can go in here to this gear icon right here click on it and show only modified properties so once you do that let me move myself once you do that you can you only see the properties that are um what's what's what's the word that I have messed with right so it's the light intensity that needs to be one is the indirect light intensity that needs to be three n is the volumetric scattering intensity that needs to be 0.25 spawn ignore collisions I think this one is already doing that let's just see we can search um or wait actors conclusion handling okay we don't care sorry uh we don't care about this one ignore it I guess I'm getting tired anyway uh so now we have our sunlight rotated uh new sunlight rotated as well as it has the correct strengths and so on let's compile it let's save it and for now let's close it and we will open it up shortly actually um now what I'm going to do is actually let's go for lit version I'm going to delete my directional light straight up just delete it right and instead I'm going to take my sun blueprint and add it in easy as that that's it that that's it now you have successfully replaced your sunlight with or directional light with a blueprint that contains a directional light what kind of functionality does it give you well glad you asked if you open a tab and you go to let's make this smaller and that's also smaller and you go to the event graph tab right here and then you will see that you can add events that happen right you can control it you can rotate it and so on and rotating is the key thing so what we're going to do is we're going to say okay when we begin play so event begin playing when we begin playing we want to get so we want to take this directional light just drag it over take it and drag it over here we want to take this direction light and get actor wait get rotation get World rotation get world rotation right so we want to ask okay what kind of angle are we one second what kind of angle are we dealing with at the start of the game right and that's going to be the angle at which the current sunlight is so it's going to give you give us a rotator and then I'm going to just simply create a new variable here click on the little plus sign and type in um let's go for uh start rotation start rotation and the type of our variable is going to be a rotator and it's going to be not public so it can only be accessed through within this blueprint okay we drag it in and we choose to set start Rotator or set start rotation we don't get it we set it right so we build this blueprint with basically these three numbers right here okay so the way you do it is event begin playing you connect it to set and the value you connected to start rotation and that's that now once you press the play button this will be will be registered or will be filled with the rotation value of the current light angle right that that we have in the scene okay we compile it then then what we want to do is um every tick of the game so begin overlap we don't care about that we can delete it but with the tick at every tick we need to check if we have messed with the sliders we haven't created the sliders yet don't you worry we will but we need to check if we have messed with the sliders and if we have then we need to set a new rotation for the directional light so let's do that um I believe it's going to be just set World rotation right set World rotation for directional light which is that Auto saving one second and then the new rotation we will most likely be breaking it so I'm going to say make rotator make Rotator is very nice because it gives you X Y and Z like rotation along X along Y and the lungs is that axis well actually X is the rule axis so for us the roll will never change because when you imagine Shining Light through a flashlight and you just roll the flashlight right you just rotate it along the angle at which the light is shining that does not change anything right so the rule we don't mess with um how do we do this so we get the we have the rotation already right the existing rotation so I'm going to just take it start rotation and get it so you just drag and drop it and from here from the left hand side drag drop get start rotation and what we will do is we will break rotation or break rotator then we will say that yeah we never change X right you never change X but you sometimes change Y and the way you change Y is you take the existing rotation and you will add some value to it right so if you keep adding a value it's going to keep rotating but in our case it's going to be a single kind of a application of of of a value so you you change the slider it rotates you change the value again to let's say a Negative Zone it rotates back uh so for y pitch we will be adding so plus sign we will be adding some value to it like that and for Z yo we will also be adding some value so let's just copy paste it drag it over here connect it like so okay these two values um I don't remember which one is which I believe I need to need to remember uh one second I have my notes Here the Y should be Y is vertical okay Y is vertical Z is horizontal rotation well the okay okay so what we want is we want two values one for horizontal and one for vertical right so I'm going to be creating two variables the vertical value V value and H value like that and both of them are not rotators they're going to be just float numbers float is digits or numbers that have numbers after a comma integer is full numbers floats are numbers that have Precision that goes on after the comma so like 5.321 right uh is is a float okay so V value goes in here get V value like that and H value is going to be here get H value like that okay a little bit dirty but should should work just fine all right so now how do we write how do we how do we write these values right because we can't just create a script here we need the the values to be read from the uh freaking uh one second I'll I'll get to it from the menu so what we do is we compile we save and we need to access that menu that I showed you at the start of this chapter right so to access that menu we will go to VR template we'll go to Blueprints and here we'll see the widget menu so that's the one that we want double click it and basically here you see reset orientation restart real live and we will mess with those with the design of it in a little bit but for now we just want to add more right we want to add two more sliders one horizontal one vertical uh to do so let's minimize those and simply start rearranging the the menu items that we currently have so first things first the vertical box needs to go because we will want one horizontal slider here one vertical slider here meaning they are stacked horizontally rather than vertically right so right after the Border this one needs to be a horizontal box so what we do is we right click on it and we choose to replace with horizontal box like that or we can also wrap with a horizontal box if you um if you prefer so but I I just like replacing things so let's do it that way replace with horizontal box now you can see that under our horizontal box all three buttons here are just kind of stacked horizontally that's fine that that's that's okay because the next thing that we're going to be doing is actually taking a vertical box and reapplying it on top of the or inside of the horizontal box so all of these elements will be stacked again um vertically right so this might seem a little bit a little bit weird but trust me it's going to start making sense really soon so let's just search in the palette for vertical box and just drag it on onto our horizontal box like that so that's going to be one of our elements or basically the element that holds our horizontal slider as well as the three buttons the next element is going to be um size box but maybe uh do we do it now yeah we can do it now so size box size box is very useful when you want to control the size of things that are inside of the box right so I'm going to take that and drag it onto the horizontal box as well so now we have vertical box here size box here okay for the vertical box we want to create um we want to add these three um what you might call it these these three buttons here uh into the vertical box so the way you do it is you just take these three buttons and just drag and drop them in into the vertical box bam es like we haven't changed anything right but actually we have because now we have a horizontal box so things are stacking in the horizontally in which we have a vertical box and a size box meaning that now anything that goes into here can be placed to the right of our menu for instance the height slider of our sun and that's actually what we're going to be doing right now let's just do it slider bam uh drag take the slider drag and drop it into the size box bam and you do need to make sure that it is vertical I don't remember where oh there it is so you select the slider and you change its orientation from horizontal to vertical and you can name it as well so I'm going to name it the slider there we go so now you can see we have our little slider do that right here of course we will be changing a bunch of things about it but for now yay this works we're happy okay then let's just minimize the size box uh we we have it going that's that's good and now let's focus a little bit on the um left hand side right so reset orientation restart button as well as relay buttons all of these have too many words in them and the buttons are too big so what I want to do is I want to change the spelling so all you need to do is just expand the buttons on the left hand side select the text and here under content text you just let's say reset orientation will be o for orientation restart button will be R for restart and real life will be a q to quit or Q There we go more compact well not for long not for long okay how do we um actually let me let me just introduce a slider into our vertical box here so that we can then talk about how the hell do we arrange these things on the left hand side so if I just grab the slider and drag it onto the vertical box here you can see that it's neatly placed here but it's so small it's such a mess we want it to be really big so so that we can control the position you know in a much more granular way so to do so our slider which we will rename F2 by the way to rename things we will change this to horizontal slider H slider there we go and we will add we'll right click on it and we will wrap it with a size box size box there we go bam and now with the size box and this is going to be the first time that we actually used this icebox right we will choose a select the size box by the way and then choose with override and height overwrite and for with override I will choose 700 enter bam you can see how big of a slider we've got yeah and then for height overwrite let's choose like 40. so that there is an offset from the buttons speaking of the buttons those are a little bit yikes a little bit uh weird they they look quite quite weird so let's make them better or worse it depends on how you look at it let's create another horizontal box like that drag it into our vertical box component like that so it it lives here now and grab these three buttons with the shift and and drag them into the horizontal box uh perhaps we don't want it to be underneath the slider so I'm just going to oops let's add that one up let's try again there we go so you just change the position right the horizontal box goes above the size box okay now on to the alignment inside of the horizontal box or rather maybe we should probably work on the right hand side slider a little bit to increase its size because that's the height of the sun right so we want to increase that size as well um or rather it's going to be like let's go for time of day I guess and that that's that's a bit better so in terms of that for vertical uh or sorry for for the size box of the vertical slider uh I can just choose width and height overwrites again and here I'll just say 440 sorry for width and let's go for 300 for height perfect something like that okay so now things are pretty damn ugly but everything is where it should be or rather at least on the left hand side is where where I want them to be now it's all about alignment right so let's take a look a horizontal box is aligned in the border of that and fills the whole border the horizontal alignment is to fill set to fill and vertical alignment is set to fill that's fine then we have this vertical box that also tries to fill the Border I'm not sure if it should perhaps we could do a centered and centered like so I think that that looks that that might look a little bit better right then we have horizontal box right here that definitely you know all of the buttons should be centered and vertically they can be filled that's fine and is that that yeah that's that's it that's it right something like this should be should be good enough and then just working on the sliders while our horizontal slider we can indeed uh have it like that or we can also say that our minimum value is -1 and our maximum value is one thus having the slider right in the middle and for the vertical slider same thing minimum value minus one maximum value one uh it's a little bit offset that's fine um and yeah that's that's that then we have our sliders that are working let's think promise a promise last thing about the graphics of this if I were to just uh select let's see the horizontal slider and I were to is it under style yes it's under style uh normal thumb image and I've heard some image if I change these images to some other image that I have for instance do we have the or we have the Paw but the Paw is black um okay one second I'm just going to check um if we go to our to our our materials is it yeah cat or but that's the material where's our textures um apologies for this just give me a second just just a moment okay that that uh show me where the Paw is oh it's under widgets okay so we have this paw texture right that was done in Photoshop and what we can do with it is we can invert it to be white right so that uh in the menu it pops a little bit better to do so uh all you need to do is just open it up in Unreal Engine or actually let's make a copy of it first so let's go in here and for the texture let's just uh Ctrl C Ctrl V copy paste F2 and call it Paul White or white open it up and for the brightness curve of this image which is 2 minus one and now it's white inverted many ways to do it by the way um that's just one of them okay so with that done we can go back in here and for the slider instead of Paul we can use paw white you can see that the was the name the aspect ratio of it is complete garbage so what we will do is we will say that it should be uh the size of it should be a square right because our image is square um and I believe if I remember correctly it was uh 40 right uh like this the size of it was 40. so let's go for 30 for the normal thumb sandwich something like that looks good and then for the actual um once you hover uh your your controller over it it should increase in size so the hovered thumb image we choose poor again or sorry Paul White and here for for the size we do let's go for 50. let's Let It climb okay so once we hover it it's going to increase in size same thing here um I'm just going to be fast and not repeat myself too much or white can I just drag it no no we can't or white there we go image size 30 by 30 image size 50 by 50. okay that's it that's our that's our menu I think it's time to actually test it out you know to see if it works or not if I press play compile and save don't forget that oh my my quest link disconnected while I was recording um so let's just keep out of there is this alive that's alive that's good and let's press play we're good we're good now if I look at the menu bam that's that's very nice and if I I can control the mouse you can see as I'm hovering my uh my controller over the POI it becomes bigger um here as well okay that whole thing works perfectly so now we need to connect we need to connect our controller or sorry our menu slider value to our sun blueprint values right so the way we do it is in our widget menu we need to actually access the the graph right and the way you do it is top right corner graph ma'am and here you already have a few um a few functions on clicked it once the reset orientation button is clicked then it should reset the camera and so on so open level so when you restart the level restarts and when you quit you quit right so now for us to actually start start using this uh the first thing that I want to do is I want to set the the values of the sliders right or uh sorry I want to get the values of the sliders so to do so all we need to do is for instance select the age slider the horizontal slider right like so and here in the horizontal slider once you have it selected under variables you will have uh different events that you can call for and the event that we want to focus on is on a value changed right so when you change the value of a slider it should trigger so we click on that on value changed H slider I will do the same thing for V slider right now so if you missed it don't worry be slider on value changed click the plus sign bam so what happens when we change the sliders we need to transfer that information right I will call for get All actors of class get all actors of class and here I will choose um Sun BP our sun blueprint ma'am so this will fish out every single Sun blueprint that we have in the scene in our case it's just one but we still stop that in our case it's just one but we still need to specify that you know we're extracting only one so it gives us an array of actors instead from this array we will get a copy get one right get a copy like that so this output right here is our sun blueprint then or the sun blueprint what we will do is we will set wait let's think um yeah we will set V value remember those variables V value and H value that we have set up in our sum blueprint so I'm now filling them in right here set V value and our V value will be the value that we get from the slider right here bam connect it like that and of course don't forget to call the trigger like so and that's that that's it that's all you need to do so if you missed it let me repeat repeat it much faster get all actors of class sign VP right here get a copy right here and in this case oh sorry that was the H slider I'm stupid that was the age slider so we're not setting the V value we were setting set H value like that and here we set the value trigger and don't forget to actually connect the slider value into V value okay so that works that works great and what we want to do now is to say okay let's say we take this and we change the value to um the values are between -1 and 1 right so we changed it to one right and we close the menu once we start the menu again our value is going to be reset back to zero so we don't want that we want to somehow save the values or for it to check which values were we were at before we closed the menu right so we need to do one more step this is almost there but the last step is for event construct which we have here in the top event construct for that we still need to and actually let me just drag it over here at the bottom it's gonna be easier for you to follow along there we go and I can for instance stay here even construct we still get all actors of class [Music] it is just the fastest way for me to call for sun blueprint sunbp you can also copy and paste if you want to get a copy like that and then from here I will set value uh sorry uh let's let's think give me a second um I get it and then I extract a v value get V value and get H value and then with these values because these are writing into those right so we check what kind of values do you have and the values that you have every time we construct a menu it's going to take those and we'll put the sliders onto those values so our age slider get each slider like that set value that and H value goes in here right so we start the game we mess up the menu right so we change the sliders up the values in the zone blueprint change and then we close the menu we open it again and it what it does it reads the value and sets the sliders to be at that value right so it the sliders don't reset every time we restart the game hope that makes sense then let's find the V slider drag it in here get the slider set value like that bam bam and that's it that's it this should be enough for it to work at least on the technical side one last thing to actually fix is the blueprint like that what was the word the the math I guess uh with within the blueprint but within the sun blueprint we need to change a few things right because here it's going the the numbers that are going to arrive are going to be between -1 and 1 and we don't want that we want those to be in degrees so horizontal value is actually pretty damn easy all you need to do is just take the value that you have you multiply it multiply by 180 and you're good to go right minus 1 becomes minus 180 plus 1 becomes plus 180 meaning you have full 360 degree coverage for the vertical value it's a little bit um a little bit more yucky I guess or um it can be it can be pretty simple but I would suggest uh mapping it right so what we what we can do is map range clamped like that connecting it like so so map range and as long as we anticipate that the value the range is going to come in in between -1 and one we can see that it needs to be remapped to let's say -15 and 15. so -1 becomes 15 degrees down for the Sun and one becomes 15 degrees up for the Sun should be should be good to go by the way let's just check okay it's at -20 well we'll see we'll see uh it should be good enough we we can compile this we can save this and I think we're ready to test it out so let's do so let's do so so it seems like everything is kinda working it's a little bit laggy but that's fine and we have our menu and if I were to change the horizontal rotation of the sun let's look at something nicer uh wait up close that can I please yeah there we go turn turn turn turn up there we go that's nice and again the menu if I just change the rotation works and what about yeah the verticality also works and let's mess it up so this one goes all the way up meaning that it's a Sunset and then we have it somewhere there we close the menu we open up the menu again and there where they need to be right yeah perfect okay that's what I want to see so that works that works great I'm happy we're done with our we're done with our sunlight Dynamic sunlight of course you can make it nicer you can make it more profound and there there can be more bells and whistles to it but the Baseline is there and you can build up from from here okay so now with this we can move on to the last step which is going to be or last instance of this course which is going to be switching up the objects to other kinds of objects chapter 3 I guess I'll see you there right so the third chapter of our course and the last chapter of this particular course is making an object that you can trigger a change in right in terms of geometry so you can switch or shuffle through multiple different objects and the way it's going to work is going to be very similar to what we've done with material only with a few additional things and also we want to be able to grab the object and so on we will introduce that functionality as well as a small little bonus for you for those of you who have stayed for so long right so the first step to do as we always do is to create a blueprint I'm going to just right click here in my blueprints folder and choose blueprint class like that actor blueprint bam I'll call it interact object you can call it any any way you want I prefer to just say interact object or interact object on table whatever probably you're going to be placing it on the table then you double click it and here you will want to create a static object or sorry not object static mesh so under components we add static mesh not instanced just a static mesh like that and this static mesh that we will have this one right here is going to be a com container which will hold all different states of of the meshes right so this can be a book this can be a giraffe this can be um oh whatever a banana right we will be able to shuffle through the different states of the static mesh within our event graph right so for now this can be even empty if you wanted to well with that being said I don't really want it to be empty so I'm going to go in here for the static mesh and I'm just going to choose um one of the static meshes that I already have um you might not have it so probably it would be a good idea for me to show you where I get my different assets or small objects from and that is from quixel bridge so if you go to window um wait apologies it's not window it's here um adding the the little add button right here quick sell bridge if you open that one up you will get this tab right here which is basically quick sell Mega scans library inside of Unreal Engine from which you can download anything you want and then under 3D assets here you can download um for instance for instance props books you can just download some books right to shuffle through I have already downloaded a few things I can show you if I just go to my mega scans 3D assets right here I have banana I have blue and red book I have blue book curly bun and a toy giraffe right so these are the objects that I have downloaded from quicksell Mega scans okay with that done we can go back in here interact object right and first the static mesh select it on the right hand side then you will be able to choose um the mesh that you want so in this case I will go for Azure f why not as toy giraffe there we go something like that then what you want to also do with the giraffe is you want to simulate the physics for it right so or not the giraffe this is just a you know this particular geometry but for the static mesh right you want to simulate the physics for it so you take Mark that you want to specify what's the mass of it so let's go for 0.1 kilograms you can go a little bit more let's say zero point see it's heavy 0.5 half a kilo and then you want to make sure that gravity is indeed enabled I believe that is going to be that we won't need to do anything more with this okay so once this is done you will notice that now if you were to compile save place the object and press press the simulate or the play button you wouldn't be able to see the giraffe and that's because it will just fall away just through the the freaking floor so we need to fix it and the way you fix it is I will show you where this curly bun right here so any object that you want to be able to grab and that you want to simulate the physics 4 needs to have its com its collisions built and the way you do it is you open up let's say our curly button we double click on it we open it up right in our static mesh editor we go to Collision right here this is an important step by the way so make sure that you're following along Collision and for this button we could just add a sphere simplified Collision but I will just Auto convex I'll just use Auto convex Collision I'll click on that now if I were to move Myself Away one second there we go on the right hand side you can see convex decomposition yeah convex the composition we need to hit apply there are sliders to choose from but this is a relatively simple mesh so we just hit apply and it should be um doing just fine let's try this again Auto Converse Collision apply yeah seems like it's it's gonna be working you can always check with player Collision enabled you know what what what kind of a shape it's it's using or visibility Collision like that let's hit save uh the button is done uh let's just go through um the toy giraffe I already did it for the Toys R Us so if I were to um check you can see it already asks me would I like to remove the Collision so it already has it enabled right so that's good uh I also did it for the banana and let's just do it for for the books real quick so Collision Auto time I'll close that probably have to have to save it that's fine though Blue Book Collision Auto can see that uh applying sorry apply now Collision is there it's it's shown in green perfect save that close it okay so with this done let's check if it's actually going to simulate properly let me compile let me save let me just place the actor or the blueprint in the scene so of course on the table right uh where's our interact object you can see that I've already tested this out as well um a little bit higher up just slightly something like that and put on the headset of course yeah let's let's check this out so now if I look at our little um how do I call you there you go if I uh giraffe toy if I look at it it's right on the table meaning that during the simulation it just fell down and collided with the table that's great and just like my controller fell down and collided with the floor I think it's gonna gonna be fine okay so now with the giraffe uh kinda at least being simulated properly with the physics let's actually test it out once more this time I'm going to have it like rotated so that it falls down awkwardly and but there it is okay straight on the table so that means our our physics physics works right let's reset that and now let's let's introduce the functionality of being able to first of all grab the giraffe and second of all change the giraffe into a banana so to do so let me just uh for the inside of the blueprint for the static mesh I want to create a component that's called grab add grab component like that and just drag it onto the static mesh right so that is a part of the static mesh compile save play ah wrong wrong arm go in here and if I were to just there we go okay there there's there's my little giraffe and I can have it here I can throw it it works it's a little bit laggy though that's fine that's fine okay so with this uh Collision working and we can make it a little bit more uh a little bit faster if we were to simplify the meshes for for the floor Collision but that's fine uh with this Collision working now and and as able being able to grab the giraffe let's do the switcheroo the mesh Switcheroo so how do we do this well in the event graph the first thing that we do during event begin play is we specify actually do we need to do anything for the at the start of the begin play maybe not maybe not because all of it is already already working so actually what we need to call for is the interact event right and the direct blueprint event right remember we always use that interact interface to be able to shoot at the object to change its state so to do so we go to class settings or sorry class defaults um no it was under class settings yes implemented interfaces there we go add interact BP that's the blueprint that we are using for this interact BP now we have this interface here we do need to compile it and then we just simply right click and type in interact Advent event interact so once we shoot at the giraffe um it should change into a banana right so once this is done and also it should not just change into banana Well for now let's let's change it and then we will add more functionality so we can just simply do uh Set static mesh bam already has the static mesh anchored in right because that's the only static mesh that we have and the new mesh should be a banana bam banana compile save let's try this out and we just move next to this grab it yeah that works put it back shoot at it and there goes the banana okay so I think I forgot to add Collision or the banana let's see let's just quickly see Mega scans 3D assets um banana open that one up Collision oh there is there is so Banana does have a collision so it might be because um our once the banana is spawned it spawns inside of the table so the Collision just messes up so what we want to do is before or after now before we set a new static mesh we want to move uh uh locally so local offset add local offset to the static mesh Right add local offset static mesh like that so that needs to happen before we change it into a banana and Delta location let's just go for something like 10 centimeters in the set axis and also don't forget to tick mark this teleport option or else it's going to just shoot up and the physics will will calculate so it's going to have inertia and it's just going to keep on shooting up right so teleport enabled uh this should do the trick let's try okay yeah there we go yeah and every time now I shoot at the banana you can see that it okay you can see that it lifts up by uh 10 centimeters right and it seems like that maybe the damping is a little bit too much uh so let's go into our interact object uh select the static mesh and here for linear damping um drag Force added to reduce linear movement I would say maybe we can do like three times more so 0.03 right this will just uh make sure that the when we shoot it the collisions are are well it slows down a little bit faster right 0.03 and now one more thing is if if we add an offset upwards we also want to reset its rotation right so it might be weirdly rotated we want to reset it so I'm going to say um set World rotation for the static mesh like that and it should be zero zero zero make sure that you make it larger like that and choose teleport like tick mark teleport option as well now to be able to shuffle through oh my God come on to be able to shuffle through these these components is to one second to set static object so only here so we will always be resetting the rotation we will always be adding a local offset upwards and then every time we shoot it changes to a different different mesh so here we create the multi gate multi-gate like that Perfect come on give me that go in here uh it should be looped yes and output 0 is our banana output 2 or output one sorry is our how is that bun bun I believe yes curly button there we go add pin output 3 is going to be our uh book something like that okay compile save let's investigate press play now um let's do it this way where's the camera and there we go we grab the banana we we look at the banana come on okay we put back the banana we hit it again and now it's a bun throw the button down now it's gonna be up a book that fell through okay so in terms of collision you can see that we probably need to to to to fix the um the interaction like the the Precision of the collision and I'll show you how to do that in just a second but the functionality is there and we are going to be able to just populate the scene with a bunch of objects that can be like the form of them can be changed by the user by just simply shooting at them okay so the last thing to do for us to make the collisions work is having more precision and in terms of virtual reality I wouldn't suggest amping up the resolution because that uh signals because that might not be very healthy for the performance but instead actually simplifying the collisions so in this case for example I have went on selected my tabletop here pressed the browse to button opened up the table top in here and I just created a box Collision for the tabletop because I mean it's it's a box right so we don't need it to be precise and now if I were to press play try to show you it if I were to come on um whoops let me change the the color wait I agree that's fine okay if I were to Boom door close change the color um now you can see that the the the book is still kinda vibrating but even if I put it oops that's that's a freaking eh come on eh even if I put it like on the edge of the table but that's fine if I force it into the table it's going to be spit out so now the Collision plays much much better right well maybe not that that well but you get what I mean right but the flow the problem is still for instance with the floor see I mean it kind of works but oops come on but not really come on just if I were to drop it hmm of course when I try to show it to you oh there we go okay so it sometimes goes through the floor so I'm going to show you on the floor what what I would change and how I would change it uh we simply select the floor we go to edit blueprint floor like that and oh sorry sorry uh not added blueprint floor but we actually need to just simply find that the floor mesh right so um here once we select our floor blueprint we can go to brap513 because that's the geometry that is used for the floor right and then we can browse to the asset right so that's our static mesh that is being used so while the issue with the table tabletop was just fixed by using a box Collision rather than or concave Collision rather than a complex condition in this case it's going to be a little bit trickier because the underlying reason of why the Collision here doesn't work is because the floors slap the floor top is actually a thin piece of mesh right so the geometry of it is bad it's wrong so the way we can fix it is well there are two ways one way is just simply using a box simplified collision and saying um that the you can see that now this box Collision is applied here um and just stating that the extent for Z is uh slightly larger so let's say one centimeter or something like that and then call it it calling it a day or let's remove the collision and instead we can go into our settings plugins mesh edit wait uh yeah so you could go to into modeling tools I believe modeling tools mode include the suite of indirectors yes so we could use the modeling tools to thicken the actual geometry of our mesh right here right in our case we will be simplistic and we will not use the 3D modeling Tools in Unreal Engine instead we will just simply create that box simplified Collision add the Z extent of well I'll go for like two centimeters because if you do like let's say 100 centimeters you can see that box um the Collision box appearing which is way too big uh so we can do like well actually you can do like the 10 centimeters and then an offset of it um and Z by minus 10 and now it should be or sorry minus five because it's centered minus 5. there we go and now it should be all good to go we just hit save close that press play here yeah and if I were to really let's go for something like this and a book if I were to really kind of force an intersection with the floor you can see that it still works right so it's all about the geometry the having clean geometry having clean Collision geometry and all of that if you have a clean 3D model you will not need to you know amp up the resolution that's costing you a lot of performance that you could otherwise spend on nice light and materials so that's the idea and that's that's the principle and that's how you how you work with this this kind of a things right hope that this was informative uh the rule or the name of the game is if you want the collisions to work properly all of your geometries need to have thickness right okay with this done I think we can call it a day we have ourselves a scene that is my opinion um ready to I mean it's it's fully interactive and now the only question is of scale of how many uh objects are replaced with these actors that can change material that can change their shape that can change their transformation or meaning opening and closing and also the Light fully interactive scene once you're done with it to package it you just go to platforms choose windows and just simply click on package project right it's going to ask you where do you want to save it you just save it and then you're good to go then you're done right okay I hope you enjoyed this one and I'll see you in the next one bye [Music]
Info
Channel: Gediminas Kirdeikis
Views: 18,871
Rating: undefined out of 5
Keywords: architeture, design, arch, architec, proces, how, client, clients, rhino, family, house, lithuania, company, very, good, architecture, vray, d5render, render, real time, free, for free, alternative, rtx, gpu, bim, revit, archicad, section, dynamic, drawing, visualarq, visualark, visual, arq, v ray, v-ray, skechup, material, rhinoinsiderevit, rhinoinside, rhino.inside, .insiderevit, zaha, hadid, beam, block, ibeam, grasshopper, gh, adaptive, shecule, schedule, cinematic, d5, d5 render, course, tut, ue5, unreal engine, archviz, VR, virtual, reality
Id: u3yk75fUR-U
Channel Id: undefined
Length: 96min 47sec (5807 seconds)
Published: Wed Jun 14 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.