top of page
Jonathan Bardwell

Creating & Implementing custom hand animations for VR in ue4. (Part 3)

(Part 3) How to set up custom hover animations from the BP_PickupCube actor.



Hey Everyone, Welcome. If you haven't already seen parts 1 and 2, I'd recommend checking them out first before following along.


The first thing we need to do is open up our BP_MotionController as we need to make a small change there first. Find the code in the Comment named Update animation of Hand. We then need to find the second "Set Grip State" set to "CanGrab" and promote it to a variable.


We're going to name this Variable "Hover Animation" once you compile the blueprint your variable should be set to "CanGrab" by default.



We can now close the BP_MotionController and open our AC_SetHandAnimation component.


In here we're going to find some empty space and create a Custom Event Named "Set Hover Anim"



The next thing we need to do is copy our our "Cast To MotionControllerPaw" and the Left and right controller Targets so we can access our Hover animation variable we just created.



From our Left and Right controller targets were going to set our Hover animation for both.

Simply drag off and search "Set hover Animation"



Your blueprint should now look something like this.



The next thing to do is connect our Set Variables to our custom event. If you would like each hand to use individual animations you will need to create to inputs in your custom event, one for each hand but for this example, we're just going to have them do the same animation.


We can now comment on our code and call it Set Hover Animation. I'm also going to select our Custom event and set our Hover Animation Default Value to "Can Grab"



Now we can jump over to our BP_PickupCube in our pickup cube were going to create an "On Component Begin Overlap" for our (static mesh component), the cube.



With our begin overlap in our scene, we need to get a reference to our AC_SetHandAnimationComponent so we can access our new Custom Event "Set Hand Anim" we created.



After connecting our On Component Begin Overlap To our new "Set Han Anim" node we can promote our Hand Animation to a variable, Make it public so we can access it in the viewport.



(I realised I have some variables I'm not using from past tests so I'm going to remove them as well.)


after setting the "Hover Anim TO Use" to Public hit compile and your new variable should default to "CanGrab" but before testing I'm going to reorder my variables so they make more sense in the editor when we change our animations


You can do this by dragging a variable either up or down and letting go.



We can now test our hover animation by selecting our mesh in the editor and setting the animation we want to use.



If your object doesn't need a blend space animation I'd recommend keeping it blank.


In the Giff below I've set each BP_PickupCube object to use a different hover animation.


However, if we try to hover over multiple objects with different hands you'll see our animations play at the same time. But we can fix this pretty easily.



We need to open up our AC_SetHandAnimation component and in our "Set Hover Anim" custom event add an input called Hand of type Actor and make sure its Object reference.



Don't forget to name it hand, While we're in the graph I'm also going to convert all of the Cst nodes were using to Pure Casts. You can do this by right-clicking them and "Convert to Pure Cast" this helps with code speed as we don't need to check if our cast failed.



were now going to do to check if our controller matches the hand touching to object. We can do this by dragging from our hand Input and searching == to check against the left hand and we will need to do it for our right hand also.



After we have both our == nodes for both our hands were going to add two branch nodes. We want our first branch connected to our custom event and from the False channel connect our second branch. Connect the left controller == to our first branch condition and our right == to our second branch.



Were then going to set our "Hover Animation" using the true channel of each.



Now in our BP_PickupCube and can get our "On Component Begin Overlap" other actor pin and connect it to our "Set Anim Hand" Hand input.



We can now jump back into our project and if we move our hand over multiple actors our hands should work correctly.



And that's how we can change our hand animation when we hover over an item. I really hope you enjoyed this tutorial.

 

If this helped and you'd like to support what I do why not head over to my Patreon where I have a variety of VR content available for download as well as one too one tutoring if you need help.



If you enjoyed this or found it useful please consider Subscribing to my Youtube channel where I post regular VR Tutorials for Unreal Engine 4 and Blender.



or if you're looking for somewhere to hand out or need help with something VR, Game dev or 3D related maybe consider joining our growing discord community of over 300+ Vr developers.



Until next time, stay safe and I'll see you then.


Bye.

149 views0 comments

Comentarios


bottom of page