Hand Actor Collision - Unreal Engine VR Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
having a player collide with the environment is a very interesting mechanic that can not only allow for a player to have some very interesting interactions with the world that you create but can as a developer allow for you to restrict a player at least somewhat to the world that you create so in this video i'm going to show you how to use a physics handle to create hands that will follow along with your motion control components allowing for the player themselves to move outside the balance but restricting their body from going outside the balance with it before we go ahead and jump into that if you enjoy this video and watch even more just like this one be sure hit the like and subscribe button down below and while you're down there let me know in the comments what kind of tutorials you guys would like to see in the future and with that let's go ahead and jump right into the video so i've gone ahead and got our project open so to get started let's go ahead and start by creating a new blueprint that we can actually use to to enable these uh a secondary pair of hands that will basically fall around our most couture components so let's go ahead jump into content we'll create a new folder and i'll just go and call this blueprint now we're only gonna have one thing that goes in here so whether you create a new folder or not that's entirely up to you i'm going to go and jump into blueprint class create a new actor i'm going to call this collision hands we'll go and open that up now in here we're going to create a new pair of hands that we can actually use and we're actually going to end up attaching this to the player itself and we'll actually have a function as well that will automatically set everything up for us so let's go and start by creating a couple of skeletal meshes as well as physics handles that we'll be using in order to make these new hands functional so let's go and start with a skeletal mesh now i've actually imported oh let me actually name that i've actually imported a the mannequin hands from unreal engine 4 if i recall the unreal engine 4 vr template so i'll actually be using these for our manic for our skeletal mesh here so let's go ahead and jump right into here and we'll do mannequin hand right and we'll also want to do mannequin another mannequin handwrite but this one we're going to want to actually uh wrote uh invert the scale if i recall i believe it's y let me see here yeah i'm actually going to go and offset these a little bit as well uh you shouldn't have to but this just can't make sure that we have them correctly set up here these will actually probably be a little bit off rotation off of this setup but it should still work pretty well for the most part at least now a couple things we're going to want to do to both of these is first off we're going to want to simulate physics now it's an important thing to note for skeletal blue uh skeletal mesh components in order for them to be able to simulate physics they need to have a physics asset associated with them i won't be going into how and how to set up a physics asset here but you do need to make sure that you do have some kind of physics asset that is associated with the skeletal mesh so let's go ahead and simulate physics for both these i'm also going to disable gravity now this isn't necessary however i typically prefer to disable gravity when messing around with things like this it's as sometimes gravity can interfere with uh with physics handles and things like that it's not overly common however i just can't do it as a sort of precaution i guess you could say and then let's go ahead lastly we'll jump down here to our collision here i'm actually going to do a custom collision here i'm going to want to overlap our pawn and um this is something that you probably do want to do as for the most part our player is going to be a pawn and we want to make sure that our pawn is not going to interfere with the skeletal mesh components at all it'll be kind of weird if we put our hands down to our sides and they can't reach our sides for whatever reason and then i'm also going to enable our collision we're going to make sure query and physics is enabled here and let's go and do that for our other hand here as well click enabled and our pawn is overlapped and that should be it here in our skeletal mesh the last thing we're going to add is a couple physics handles so we'll call this physics handle left and physics handle right and that should be it oh uh actually that's not it uh the physics handles so um here in our physics handles we're going to want to actually disable soft angular self linear and interpolate target now this may vary depending on your on the project you're doing this will essentially make it just a little bit snappier so it'll actually be a little bit um closer to our most extraordinary component our target location rotation you can enable these and mess around with these however if we leave it as the default settings it'll actually be a little bit spongy uh it'll also lag behind the motion control component a little bit uh we'll essentially get something where our hand will cut where it'll kind of follow around and then once it does kind of reach it'll kind of go back and forth a little bit so it can be a little bit funny i don't prefer having these enabled um just because they it gets a little bit spongy but that's entirely up to you so i'll go and leave that so next let's go and create a function that we can run on startups that way we can make sure everything gets set up correctly i'm just going to call this um setup is what i'm going to call this now this is going to be called within our player and the reason being is we're going to need a few values from the player as well and we're going to store them here within our collision hands so let's go and start by creating those variables we need so we'll go and create left motion controller and we're going to need a motion controller component and let's go and create a second one as well right motion controller and we're going to want to set both of these right here set and we're going to make that look a little bit nicer and those are going to be a couple of values that we're going to need from our player once we actually go and spawn this in uh in addition we're also going to need to be able to make sure our physics handles and our skeletal mesh are all set up and ready to go here we can of course run this to begin play however i just think running out all this at the same time will just save us a little bit of time here so let's go ahead grab our physics handles and our skeletal meshes and for both of our physics handles we're going to want to grab component at location with rotation now the component value is going to be the corresponding skeletal mesh in this case we're working with physics handle left so we're going to want our left skeletal mesh and then for our location rotation this is going to be the point that we want to grab this at so in this instance for example we're going to want to get world transform of our skeletal mesh and then i'm going to go and right click split strut split pin struct and we're going to do location rotation just go and feed that in and and then we're going to do that again for our right physics handle so grab component now you may also notice here we also have grab component location now you certainly can do this however we'll kind of get a funny interaction where our hand will kind of dangle at the target location it won't actually try and match the rotation that we want it to be at so by by grabbing a location rotation we can make sure that we'll have um we'll have a little bit better um we'll we'll have the uh at least a more correct rotation now if you also want to adjust the rotation of your hand i would also suggest coming into here and modifying this rotation value i would probably do this by simply adding or subtracting basically breaking this rotation and then adding and subtracting to the x y and z values and then feed making a new rotator out of rotation out of that that's entirely up to you though there are of course other ways of of handling this um so yeah now in our event graph for a collision hand we're not going to need our begin play or our actor begin overlap but we will need our tick so in our tick we're going to want to grab our physics handles there we go and we're also going to need our left motion controllers which we which we assign in setup so let's go ahead grab these and in order for this to work we're going to want to set a target location and rotation what this will do is it will basically to the best of its ability the physics handle will try to take whatever component it's grabbed and try to the best to and try as accurately as possible get that component as close to our target location rotation as it possibly can so our hand itself may go through the wall or something like that however our our skeletal mesh here will not be allowed to pass through a wall because we've enabled collisions for it and we've enabled physics which is required by a physics handle so it it'll basically try its best to get to wherever that motion control component is and it might even slide across the wall a little bit however it won't actually be able to get through that wall because it's just not allowed to so let's go ahead set target location rotation and our target location rotation is going to be based off of our motion control components so let's go ahead and get the world transform for each go ahead and right click oh i mean to promote that go and delete that split struck pin and then our location and our rotation will get fed in here and we're going to want to do again the same thing for our right physics handle as well so it's going to get world transform split struck pin location goes in rotation goes in and we are good to go let me see if i can clean this up a little bit though first certainly not the cleanest work i've done there we go uh that'll be a little bit cleaner and with that we're all done here with our collision hands so let's go and close out of that let's go and open up our player now here like i said originally you're going to have a little bit of difference between unreal engine 4 and unreal engine 5's player unreal engine 5 we have our motion controller components right here unreal engine 4 stores the motion controllers as separate actors it essentially splits the player into three parts so you're going to want to grab i believe if i recall they're stored under variables left controller and right controller it might be left motion control and right motion controller and in there is where you're going to find your motion tutorial components fortunately here in unreal engine 5 we don't need to worry about that because everything we need is right here it's already all attached together so now let's go ahead let's go ahead and spawn actor by the way i'm doing this in begin play i forgot to mention that so we're going to want spawn actor and our actor is going to be the collision hands which we had already set up our spawn transform we're going to want to grab our actor transform there we go however this quite frankly isn't going to matter too much and the reason being is we're actually going to attach this as well to our actor this shouldn't be necessary however i'm doing it just as a precaution to make sure everything is all attached together and we don't lose anything so we're going to go ahead and attach actor to actor the actor we're going to attach our collision hands to is going to be our self which in this case is our vr pawn and we're going to want to snap our snap 2 for our location and our rotation and our scale we're going to keep world so that way we don't have any scaling issues or anything like that keeps things nice and simple we don't have to worry about that and then we're just going to want to run setup there we go and then let me go and run this underneath so we can see this this node a little bit better there we go and then finally we just need to pass through our left and most control components from wherever they may be there we go and there we go so that is our player all set up on the player side of course we don't need to do as much it's a lot of it's all set up within the collision hands themselves so we'll go ahead and jump into vr now and we'll go ahead and give this a nice little test run here so i'm now within our vr view uh you can actually see like i said these are not perfect rotations these definitely need to be modified uh in order to get a good rotation on these however you can't see that these are falling around our hands and so i do want to note that the physics assets for these are not perfect they cover like a small part of the palm here but i can actually push them against each other you can actually see they're they're like hitting each other which is quite which is uh quite nice there unfortunately i can't get much closer without hitting my my controllers together um but you can also see too so i actually simulated physics unfortunately it does interfere with the teleport since the teleport needs to hit um objects um but anyways so you can actu i actually simulate physics on these blocks before starting this tutorial so i can actually go ahead and hit this come on there we go and you can actually see i can push these blocks around as well um unfortunately these blocks did affect navigation too so it's not perfect but you can see that it does work which is pretty cool and with that that is a very simple way to allow for collisions between player and a virtual environment within vr as i stated the mannequin hand probably isn't the best example to have used for the for this tutorial as the physics asset is not perfect and can definitely be a little bit spazzy at times but you should have plenty of luck working with other skeletal meshes if you decide to design your own with that i hope you enjoyed this video if you did be sure the like and subscribe button down below and i'll see you in the next reality you
Info
Channel: VR Playground
Views: 1,089
Rating: undefined out of 5
Keywords: VR Playground, VR, Virtual Reality, Game Development, unreal engine 5 tutorial beginner vr, unreal engine virtual reality, unreal engine vr, unreal engine vr tutorial, unreal engine, unreal engine 5, unreal engine 5 vr, ue5 vr, unreal 5 vr, unreal engine 5 vr tutorial, hand actor collision, unreal hand collision, unreal physical hands, unreal, unreal engine tutorial, unreal engine vr hands, unreal engine hand collision, unreal engine vr actor collision
Id: Ly1XMXVdPlU
Channel Id: undefined
Length: 15min 29sec (929 seconds)
Published: Fri Sep 03 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.