Unreal Engine 4 Tutorial - Physics-Based Interactions Part 4: Drawers

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] boom we're in part four of our physics based interaction system and in this episode we're working on the chester drawers i've done the wardrobe now i'm gonna do drawers with three sliding drawers and go over some of the minor details and settings that you find on the constraint as well as physics based objects so let's begin okay so we're going to create the new class for this and this would be the gauze and much like the wardrobe we're going to have to add a base mesh to this we're going to add static mesh and this will be drawers base and there's a b for just the drawers okay so now we need to add our individual drawers and we're just going to add one at a time and test them out as we go and so we add another static mesh to this this will be four and do bottom first and i'm gonna attach it to the base like so so it's charged to it and then i'm gonna choose the mesh to be draw and we'll do or one and for this we need to reposition it obviously because we don't want it there so it's getting to the correct position now one thing to note about the constraint that we're going to add onto here is that it will get confused or respect at least the changes in the location of the mesh in the space so this location here is affected by the constraint or while the traits affect by this location so when we add the constraint to this we will do some extras of work to it so let's add the constraint first of all and in here we're going to lock the angular constraints without doing anything like that and i'm going to put this into the correct position i want it to be in so typically for the constraint here you want it to be right at the front basically where you want the uh i see that what's the handle to be so i'm going to put that over here like so and in fact it would probably yeah change this editor to zero and next here the zero okay and that's that okay so it's here so then i'm going to go to the component names and we're going to do draw bottom another one it's going to be raw bass uh draws bass and misspell it there we go do make sure you've got your spelling as i said you should have like these boxes around them when you've typed in correctly and we're going to go down to disable collision turn that on and then we're going to go to linear limits and i'm going to change the wire limit y make it limited and on here we're going to change the limit so i'm going to do something like 50 maybe uh what i do now i did 30 last time so i'll do 30. there we go now although this doesn't look it's going very far it respects the origin of the draw so you do have one little issue so if we go into this and show this working we have to draw a bottom make sure i've turned on to make physics oh and also with the toe our class to inherit the interface so interaction interface and with the tell it to handle these so uh contr actor itself and looked at component is there and the message is open draw and hit compile and then interact with rotate to can grab okay so i'll put this into the world we'll put this over here and hit play if i click on the draw here grab it it'll come out just fine but watch what happens it goes all the way back okay that's because we had to change the location of the draw in its space so what we need to do is take to update its constraint reference basically so to do that on the draws i'm going to go to the event graph and on begin play you take out the um the physics constraint for the draw button okay and we're going to tell it to set constraint set constraint reference position so we have to do is leave it at zero so we do right here is just split this and it'll be happy with the zero zero zero so now let's check that out and open the draw notice i can put it out a bit further now this time and i can't go back because the constraint is attached to the draw it will respect the location of zero zero zero which is relative to the draw location so its reference position is no longer the root of the actor but now the position where it is currently okay there's your draw now to do it for the other two drawers so go ahead on here and we're going to make a draw bottom here i'm going to set both of these and duplicate them and we'll rename this one to draw middle and we'll rename this one draw middle and ranked and we'll set those up over here so this draw middle we're going to move up and this one is going to be the other model draw to slightly different and it'll be fine there and then a constraint here we need to change the name of the constraint to use the draw middle so everything else will be left the same i'm then going to go do that again so duplicate this again and it'll be draw top constraint and draw middle will change to the top and we'll select the draw o3 and we're going to move it up through the top on the constraint just change it to reference the top one there we go so get these three other two working uh go to event graph and we're going to add them both to the target here so i'm going to add a constraint here in the middle and the top and we're going to plug them all into this because they're all child of their own drawers they should all respect each other's drawers this one's opening with the other one because i think they're overlapping a little bit their physics so they're getting caught in each other that's simple enough to fix we just change their location a little bit so click on draw middle and just move it up ever so slightly they need to do the top one as well now up slightly up slightly we've got a good gap finish one now hit play and we can open individual drawers so notice how the drawers are just moving off their own accords because of just the way physics is being calculated on them well what we can do is change the settings on their physics components to not do that so let's go into the character actor here and on each drawer you can change their physic properties so they've got their mass set up here got linear dampening here so linear dampening is that sliding motion so if i turn this up to say 0.5 and do it for each one we should see a lot better friction in the actor okay notice how they're not moving really at all if i drag it out they kind of just don't slide around really too much you can tweak these numbers as much as you'd like to get where you're going okay there you go so now we've got drawers and we've got wardrobes now with the wardrobe because of now what we've learned about the linear limits and what you have to do to get them set up quickly in our wardrobe we're going to add multiple shirts to our wardrobe so in here go to viewport and we're going to take the clothes hanger and its contents okay here and duplicate it and we'll just move it along so oh whole thing along like so and change the shirt and we'll do shirt too and the constraint here will change the name of it to close hanger one now the main thing with this is we have to tell it to update that reference so on the event graph on beginplay and drag out these references for the constraint and i'm going to set constraint reference position and we'll plug that in here and do it for both of them so now if i push play we won't have the issue of it going outside of the bounds now but we do have another issue where you can see they're off the hanger and off the rail so the reason why that's the case is because the constraints here have been moved away from their regular position so if i go to the viewport you can see this if i click on this constraint here which is in the middle over here you can see in its location settings i've risen it about 10 in the z so i want to keep it respecting that 10 there the one fast about because the y is its movement i'm going to keep that in center so that'd be fine there but the 10 needs to be z equal needs to be equal to 10. so on the event graph of this we're going to change this to b10 and i'll update the local reference position of the constraints to be 10 higher than they normally are so if i push play now we should see they're now on the hanger brows completely fine and i can bash these about and they affect each other away for this one and like so and that is us using the linear limits to create further constraint stuff so now you have your sliding drawers in the last and final episode we're going to go over how to create a chest with a lid that can open and shut like a clam shell you can watch the episode right now over on patreon.com or becoming a youtube member massive thank you to all my patreons and youtube members who voted for this series it wouldn't be possible about you guys so thank you again for your support and generosity make sure you subscribed and i'll see you all next time bye everyone [Music] [Music] you
Info
Channel: Ryan Laley
Views: 6,280
Rating: undefined out of 5
Keywords:
Id: YVJp0tL-vro
Channel Id: undefined
Length: 13min 10sec (790 seconds)
Published: Mon Nov 01 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.