VR Physics Hands & Physics Weighted Object

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] before even getting started i just want to mention a couple of things so the first thing is that obviously i've got enabled the no graph assistant and the vr developer again which i don't think i'm going to use in this video but it's enabled me no graph assistant it just allows you to edit blueprints faster it's not so probably go in the marketplace and get it if you want to be faster than blueprints that's the first thing and the other thing is that i'm sticking into like physics-based interactions so it's not like i've got all the answers you see that i'll be entering various values that are just coming out of nowhere and that's because literally that's where they come from it's values that i've been experimenting with and playing around with and i think i understand some of them some others i think i don't understand them completely so i'll try to explain to you what they are and what they meant to do but don't take everything as if all the answers when it comes about physics interaction still getting into it and that's that uh apart from that what i've done so far i just basically approach project and i the uh they reset kind of reproduction so that i can resemble myself in vr and that's basically time and anything else this is just the basic vr template and that's where we start from so let's start with the first thing what we need is a hand that is physics based and that interacts with the word we cannot have objects that have weight if we don't have a hand that actually interacts with the word and behaves as if the physics engine is manipulating the hand if you inside of the motion controller you see that the hand is connected to the motion control it's a one-to-one motion so where the motion flow is the hand is they cannot be so we need to change that first let's go inside of the hand details and we'll set that to simulate physics first and foremost and then we'll say that it's a physics factor and that's all done uh i don't think there's anything else that we need in here and then we will get this guy here and we actually re-parent the our direction graph sphere and arc spline to the motion controller and then repairing the hand mesh to the scene we get compiled and then we get the hand basically not being parented to the motion controller right now if we play this nothing will happen you won't see your hand it just basically disappears it's going to be as serious you see what the motion controller is so that's the first step the next one is going to be to get rid of the code that actually updates the collision of the hand so right now we actually said that this is a physics adapter if we want to manipulate it with physics it needs to have that collision preset but at runtime because of the grip state uh you know up value we basically update the collision to be no collisional collision enabled query and physics so we're gonna get rid of that i just kept that cut that connection and the uh next thing we want to do it's adding a starting mesh to the uh motion controller we're gonna call this hand keyboard and this is what the physics constraint we're going to use uh is going to use as one of the two components to basically uh have the hand following the motion controller uh down in here we're gonna say that these uh doesn't generate any overlap we're gonna custom we're gonna have a custom preset i'm gonna set it overlaps everything and then it's go query only it cannot be enough physics it cannot be sorry not collision at all so it needs to have some sort of collision and because we don't want it to interrupt anything else we're gonna say that this is go just query only but it's it's still basically part of the collision but it doesn't do anything uh and then we're gonna go down in here we're gonna say that it's hidden we're gonna go up here we need to give the obviously a mesh we're gonna say that it's a cube one by one and if we go in here and we actually zoom in it's just a little cube that it's not there will be basically it's it's hidden for now the next thing we want to do is going down in here and add a v6 constraint and we need to make obviously some changes so the first one is saying that this is using the hand pivot is the first component and the second component is going to be the hand mesh uh with those two done now we can see that we have a red cube there which is the first basically uh component of the constraint the second one is the actual handle if i zoom out you can see that the blue box represents the hand we're going to disable collision on the constraint behavior we don't want to enable projection uh when i had enabled it was behaving a little bit weird so as far as i understand this it tries basically to project there is a linear tolerance basically kind of a distance between where the second component first component is and the constraint is acting on it isn't it and if that uh distance is more than a certain tolerance or so we talk about linear and angular isn't it then it's going to basically project the hand to be there it's gonna just appear there we don't want that uh and we're going to say that the linear motor linear limits are all limited and we're gonna enter 90. so there's some room of movement in the linear motion so where the cube the little cube is doesn't have to be where the hand is there is some kind of muscle so i can have the cube going through geometry and then the head and stopping against that geometry uh and that linear limit ensures that you know uh basically the linear limits don't kick in straight away uh we're gonna say that all the angular are locked and then we're gonna go down here and actually have an inner motor if we don't have any kind of force that basically tries to push the hand to be where the cube is right now because then there is the 90 limit it will just be basically hanging in there and falling but we actually need to have some kind of force that says yes there is this limit of 90 in all directions but actually i'm trying to push you to be where you are now these values are totally random these are the ones i've been experimenting with so this is what was talking about and then we also have a angular motor and again i think it's 550 looking at some notes because obviously i can't remember these values by memory um and that should be basically how we set up the entire physics constraint but the last thing that we need is going inside of the physics asset which you can find under the mannequin here and then character and so on uh and we can make obviously the collision a little bit smaller because the collision it's a bit too big it gets out of the actual hand there uh we want it to be smaller he basically wraps the hand a little bit too much that's what i wanted to say and we're going to lift it a little bit as you can see there and then the last thing we want to do is give it to the hand a little bit more mass the mass is very important everything apparent everything it's related to actually the mass of the object so uh the action massing kilogram of one object and the other when there is physics between the the two going on it's what gets taken into account to calculate how the physics basically constraint to whatever it is will actually act so we need to give it some weight a device is not gonna work and 10 kilograms is the weight they seem to work for me now with that done we should be able to actually see the hands um updating correctly so we can move this guy a little bit closer here and then we're gonna actually hit play get in here and see if we got the hands here as you can see you've got the hands now if i teleport you see that the hand follow afterwards we don't care too much about it right now we can look at this in a different video but yes because obviously we've got physics constraints we should probably disable these the constraint once we teleport and update it one to one but anyway if i get close to this and then i'll step back a little bit as you can see the hand goes through but it doesn't go through the thing i'm basically hitting against that and to visualize it just a little bit better we can go in here and add a new uh static mesh i'm gonna call this controller and then let's go here and set it it's got no collision it doesn't do anything and we're going to bring up the engine content let's say okay loose and we can use the oculus mesh controller there it is and i'm going to go here where the big play is and say that actually i want to cover this not that one and set the for the right the scale to minus one so that it scales it and that should actually do and now if i go here you can see for some reason it does this but yeah i don't care anyway you can see the um actual controllers and then the hands and if i get closer here you can see that basically the hand is not going through this the fingers are going through winning curve right now we're not trying to get a one-to-one kind of collision we're just trying to have basically physics on the hands but as you can see basically i can make these objects and they're based on physics so the hand doesn't go through that and when i as you move it it snaps back and you can basically interact with the object so that's done and we can move on to actually giving weight to the action objects so let's get rid of some of these guys we don't need all of them i'm gonna leave a bunch of them i guess and then i'm gonna move this one from here press the m key so that it snaps on to the surface below it and then we can go in here and start to make some changes the first one we want to make is the mmb event pickup obviously just parents now the this after to the most chapter that gets passed to through the attach to variable we don't want to do any of this anymore so we're gonna completely get rid of this then we're gonna go to the construction script add a text render here just to visualize the weight of this uh object and we're gonna say set mass overriding kilograms we're gonna declare this as a variable kg and we're gonna expose these compile and then we're gonna get this guy here set the text get that and then convert this to a string uh append a value space kg and then we're gonna actually set it there and what we end up with is basically these guys having a um having a weight there basically written uh we need to obviously position it properly but as you can see it's that one kilogram of that so let's actually move the text wrangler so that it's where it's supposed to be i'm gonna say center uh text center and then we're going to actually move it freely forward until it's visible and then we actually go all these guys in there and select one of them and say here 180 so we can now see each one of them and we got a value we can control here for each one of them for giving them different weights so we actually can add a bunch of them so we're gonna grab the first one i'm gonna say this this will be like 10 this is gonna be other 15 this is gonna be 20 and then we can have 50 i guess and then we're going to have a last one you'll be over here and we're going to say 200 so so now we got a bunch of objects with different weights that's really important obviously they need to have the appropriate weight so that you know the physics constraint and the physics react in the right way and next thing we need to do is obviously actually now um use the physics constraint to grab the object we can't just grab it the way we used to do it it needs to be based on physics so we need to attach this budget to the hand with some kind of physics logic isn't it um so let's go inside of the actual pickup interface that's what we need to change and we're gonna go here and say that the first argument we want to pass in here it's a p6 constraint component and we're going to say constraint and the second one it's a it up mesh it doesn't matter to be honest we could scale it a flash component we could pass in a scene component but we want to make sure that it's actually the scatter mesh and i'm going to say hand compile and save and now if we go back to the cube we can see that it changed here let's compile and save and the first thing we want to do here is actually say set constraint components so we want to actually um set the hand as the first constraint and the starting mesh as the second constraint component we also want to get the reference to the component so that once we actually drop it here we can check if it's valid and if it is we're going to break the constraint and then we're going to actually lose the reference and that's all that we need in here it's actually that simple if we go back to the motion control we actually now need to call on grab the right the right function which is pick up and it's broken right now uh and we need to pass in a constraint it can be the same constraint obviously it needs to be different one so if we go in here we can add the new physics constraint and we can call it grab physics constraint that's the one that we pass here did i get the controller yes speed oh my god okay there we go and then the second one is the actual hand and that basically caused the pickup the way you you'd expect but we also need to make some changes in the release function right now we're checking if the other hand is grabbing and in that case we let go of basically that will go with the right one and so on so this is basically logic to make sure that if you grab an object with one hand and then you grab it with the other when you let go this object doesn't receive a drop call so we want to get rid of this for now we probably fixed this it's going to be broken at this at this point we probably fix it in some other in the next video i guess uh but for now we're going to just say drop so we only use the right hand i'm going to show you why the left hand doesn't work in this video we're not going to fix it but i'll show you why uh in a second so i think that's everything that we need to do i believe so let's have a look and see how these guys behave i'm going to present myself i'm going to move a little bit forward and try to grab this guy and as you can see there is something going on there and that's basically us not setting up the physics constraint properly we don't want to have the angular limit uh free we want to have everything locked on the second console so the only things we change here are the angular limits so that it doesn't hang in the way that it just did when i grabbed it and as you can see there's some pesky movement going on with 20 kilograms obviously if we go to one that probably isn't at all it's almost one to one and does collide with the the other with the geometry basically figured the down here to 50 as you can see he kind of already uh tries to follow it but it's heavier and if we go to 100 it becomes really heavy where it barely basically matches it and it swings quite a bit now obviously this is all good but it's not good enough because we can just grab this thing and it kind of hangs in there and it doesn't matter how heavy it is it's gonna just be farther from the hand that's not the behavior you probably want you want to make sure that when you grab it if it's too heavy the hand can't grab it and let's go that's fairly easy to fix though if we go inside of the motion controller and we grab these guys here and move it down we can add a new then and then we can go down in here and get the attach chapter and check if it's valid and then we can actually connect these two now with that done uh we are basically saying okay fair enough if the attached chapter is valid it means you're grabbing something with this hand and then we want to run some logic and then logic we want to run is checking for a couple of things the first one is um where both of them check for how far the hand is from the motion controller so a way for checking out iv an object is and if the hand it's capable of basically grabbing this object is by simply saying if the hand gets too far away from the motion controller because the heavier it gets the heavier it's going to pull it down then just let go isn't it so that logic is fairly easy to implement we can just say get word location duplicate these and then get the hand subtract d2 get the vector length and then check if this is actually more than a certain amount i'm going to say 20 for now and then i'm going to connect it here because we need it twice we're going to convert it to a function and say get controller two hand distance very length fiba also explains quite a bit what it does and we can have a second one here and then we can actually expose this variable as uh the max distance and we can also return the actual uh distance here uh and then that's already pure function so we can say here that this is 20 and we can say here that this is 15 something like that and now if this is true what we want to do is get in the graph physics uh component we want to get the attached actor called drop first of all so we actually dropping this guy here um i believe the drop anyway already breaks the constraint so i don't think we actually need to break the constraint i think i was doing this but it doesn't make sense now that i'm looking at it so i'm not going to do it anymore so we know we don't need to write that and the next thing we do is losing the reference so we're saying okay we're ready let go the attach factor is not valid anymore the other thing we can do is remap these actually sorry i keep calling remap it's actually map range clamped and we can say okay give me a value between 15 and 20 and give me back a value between 0 and 1 and then we can call rumble controller which is a function that we have already built into the motion code adapter and all it does is literally calling play haptic feedback using the controller the right hand and the right intensity basically um and we can use these as the intensities of the further so as soon as we get a 15 of distance it starts to basically buzz a little bit and then when it gets to 20 that's the limit at which point it lets obviously go because this this will basically fire and with that done obviously you're gonna be able to hear the hearty feedback maybe i don't think he's gonna be picked up by the microphone hopefully and uh if i get this guy obviously nothing happens but yes if i shake it too much if i'm not careful let's go and this guy here we're not going to be able to pick it up basically let's go as soon as we try and the thing i was talking about i was basically saying with the left hand we know using the left hand is because the left hand that's what he does and that's probably because of the way the template is basically set up he uses the uh same hand scan it never plays well with anything to be honest i really like it so we probably gonna fix this in the next video in which we are going to try to get the that's probably broken for for every every single one of these uh in which we are going to try oh sorry to actually grab the objects with two hands so for example if you have an object that is too heavy for one hand you should be able to actually grab the two and lift it up isn't it with the two hands but 100 kilograms you come with one equal two that's what we're gonna be looking at and that's basically how you get the objects so that we wait so thanks for watching guys hope you enjoyed the video if you did leave a like and if you want to see more of my content don't forget to subscribe so that you get notified whenever new videos are coming out uh as i was saying i probably keep going on this as it's really interesting i want to learn more myself and in the next video we'll probably fix a few things that are not working right now i was looking for example looking at the left hand the fact that when we teleport the hands interpolate afterwards and then we look at grabbing the objects with the two hands that's really interesting we'll see if we get there in the next video i want to get going the same way i did with the bow and arrow which i make a few videos and then we evolved these into something a little bit more interesting also check out that video that's really interesting i made like four different videos only for an hour and it kind of evolved into something which is actually probably usable in a game so it's a proper implementation apart from that don't forget that we also got a discord server right now setup so you can go and join i'll leave a link down in the description below and it's all we are related so we just talked all things about vr so if you have any questions if you want help from others if you have any ideas for new videos there's a tutorial channel vr counter examples channel and so on uh thanks again for watching and i'll see you next time bye
Info
Channel: Just2Devs
Views: 7,274
Rating: undefined out of 5
Keywords: Unreal, Gaming, Programming, ue4, unrealengine, VR, virtualreality, VR Physics, virtual reality physics
Id: E16JFQdiiGk
Channel Id: undefined
Length: 21min 59sec (1319 seconds)
Published: Tue Oct 06 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.