VRChat – How to Make Avatar Interactable with Phys Bones in Unity

VRChat – How to Make Avatar Interactable with Phys Bones in Unity 1 - steamlists.com
VRChat – How to Make Avatar Interactable with Phys Bones in Unity 1 - steamlists.com

This guide is will show you how to make your avatar’s glasses interactable in Unity3D using the new Phys Bones. It goes through step-by-step and should be pretty accessible to beginners and those new to Unity and avatar creation. After this guide, the glasses on your avatar can be grabbed by others and pushed around on your face or even pulled off your face entirely.
 
 

Introduction

A couple of people have been asking me how I made my glasses grabbable with Phys Bones so I decided to make a guide about it. This was doable previously with dynamic bones but now with the recent addition of Phys Bones, it’s much easier. I tried making this guide pretty accessible to people new to Unity3D and VRChat content creation, so if you have any questions please leave them below.
 
Note: At the end of this guide, you will be editing any animations for your glasses (ie: toggle animations)
 
 
 

Step One

Before you start, you should ALWAYS backup your avatar unity project before attempting something new and unfamiliar. I will not be responsible for any mistakes made
 


 
Make sure that your glasses are in your armature under your head bone (Armature>Hips>Spine>Chest>Neck>Head>Glasses)
 
VRChat - How to Make Avatar Interactable with Phys Bones in Unity - Step One - B733DA8
 
 
Then you want to right-click your head bone in the hierarchy and ‘Create Empty’. You can rename the new GameObject to whatever you want. I’ll rename it to Glasses Parent for this case.
 
 
 

Step Two

For me, by default, my Glasses Parent was positioned in the neck when I created it. We want this to be behind the glasses inside the head.
 
First, go to your Glasses (NOT the one you created) and right-click the transform component and ‘Copy Component’
 
 
VRChat - How to Make Avatar Interactable with Phys Bones in Unity - Step Two - B2CA1B5
 
 
VRChat - How to Make Avatar Interactable with Phys Bones in Unity - Step Two - 3BCD2BF
 
 
Second, go to your new Glasses Parent you just created and right-click the transform component there, and click ‘Paste Component Values’. Your Glasses Parent should now be in the same spot as your glasses, all we have to do now is move it back into the middle of your head.
 
Move the Glasses Parent along the Z-axis (or backwards into your head) so that it is approximately in the center of your head, don’t move this left or right, or up or down.
 
 
VRChat - How to Make Avatar Interactable with Phys Bones in Unity - Step Two - 6ABE03D
 
 
VRChat - How to Make Avatar Interactable with Phys Bones in Unity - Step Two - 7EE2C7A
 
 
Then drag ‘Glasses’ under ‘Glasses Parent’ so that it becomes a child of ‘Glasses Parent’
 
VRChat - How to Make Avatar Interactable with Phys Bones in Unity - Step Two - 5840191
 
 
 

Step Three

Click on your empty Glasses Parent you just made and in the inspector, click the box ‘Add Component’. Search for ‘VRC Phys Bone’. Click that and add.
 
Make sure that you add this to the empty Glasses Parent you just made, NOT the pre-existing glasses
 
 
If you don’t see VRC Phys Bone in your components list, update your VRC SDK. Make sure that you are using an SDK released beyond April 21, 2022.
 
 
Your Glasses Parent should now look this in the inspector:
 
 
VRChat - How to Make Avatar Interactable with Phys Bones in Unity - Step Three - 8F81691
 
 
 

Step Four

Simply copy these values to your PhysBone script
 
 
VRChat - How to Make Avatar Interactable with Phys Bones in Unity - Step Four - 25BCC42
 
 
These are just the values that I use, but you should change them to fit your liking as it’s highly customizable (You should change the radius value at least). Things you can change:
 


 
Pull – How much force is applied to return the bone to its original position (ie: someone grabs your glasses and lets go, how much force is applied to the glasses after they let go to bring it back to your face)
 
 
Spring – Amount of wobble when returning to default position
 
 
Immobile – Set this to 0 if you want your glasses to be affected by your movement (ie: nodding your head will bob your glasses up and down). Set this to 1 if you want the glasses to only be affected by someone’ colliders. Note: If you set this value to 0, your glasses will fly up on your head when you run forwards, as that’s still counted as your head moving
 
 
Gravity – How much your glasses will be affected by gravity. Positive value pulls bones down, negative pulls upwards. If you decide to use this option I recommend utilizing Limits.
 
 
Limits – This limits where the bone is allowed to move and is the most complicated out of these options. I recommend checking out the official physbones documentation – [vrchat.com]  as it explains it much better than I could. I recommend using either No limits if you want people to pull your glasses off your face and move them wherever, or a Hinge limit if you want the glasses to stay on your face.
 
 
Radius – You should change this value as this will be different for most people. This determines how big the collision sphere on your glasses is. Essentially where your glasses are ‘touchable’. Usually, this value is very small (Mine is 0.0002)
 
 
Allow Grabbing – Simply whether players will be able to grab your glasses within the radius collider you set above.
 
 
Allow Posing – Whether players can pull their trigger while grabbing to freeze your glasses in place.
 
 
Grab Movement – How closely the bone follows the grabbing player’s hands. A value of 1 keeps the glasses at the same position as the grabbing hand.
 
 
Max Stretch – In this case, it determines how far away the glasses can be pulled away from your face (if you have no limits). There will always be a max distance your glasses can be pulled away from you. I like to keep it at 5 but you can shorten it if you’d like.
 
 
Now, if you don’t have any animations or toggles for your glasses, you’re done!
 
 
 

Step Five (Optional)

But because most avatars have toggle animations, most of you will need to edit your toggle animations slightly, as the path in the hierarchy to your glasses ha changed. Animation can look a little intimidating for those unfamiliar with it, but follow as close as you can and it should be pretty straightforward. I will try to be more descriptive of each step.
 
 
First, you need to add your animation controller to your animator. Click your avatar in your hierarchy and in your inspector should be an animator component. It should look something like this.
 
 
VRChat - How to Make Avatar Interactable with Phys Bones in Unity - Step Five (Optional) - 8EB2BED
 
 
At the top, under the animator component is a box named ‘Controller’. If that box says ‘None (Runtime Animator Controller)’ click the circle to the right and select your FX controller. It will probably be named the name of your avatar + FX. In my case, it is ‘Christmas FX SFW’. You’ll know you have the right one when your animation tab has all your animations in it when you select your avatar in the hierarchy.
 
 
VRChat - How to Make Avatar Interactable with Phys Bones in Unity - Step Five (Optional) - 61EF4FE
 
 
Second, open up your animation window in Unity (Window>Animation>Animation)
 
 
VRChat - How to Make Avatar Interactable with Phys Bones in Unity - Step Five (Optional) - 583ADE5
 
 
Third, you need to duplicate your avatar in hierarchy. There is a bug when animating that will get your avatar stuck in ‘motorcycle pose’ and can be very difficult to fix. We duplicate our avatar anytime we are using the animation tab in case that bug happens, we can delete the duplicate bugged avatar. So just click your avatar in hierarchy and press ‘Control + D’ to duplicate. Then disable your original avatar so just the duplicate is showing.
 
 
Now we can start. In your animation tab, click the drop-down menu to show all your animations and find your glasses toggle animation.
 
 
VRChat - How to Make Avatar Interactable with Phys Bones in Unity - Step Five (Optional) - 09165B4
 
 
You should have something that looks similar to this with a yellow path and it tells you it’s missing.
 
 
VRChat - How to Make Avatar Interactable with Phys Bones in Unity - Step Five (Optional) - 2102873
 
 
Click on a yellow path and press ‘F2’ to edit the path. Change it to match the path of the Glasses Parent (Or whatever you named it) you created. Make sure the name matches exactly.
 
EXAMPLE
 
Armature/Hips/Spine/Chest/Neck/Head/Glasses -> Glasses Parent
 
 
After you do that, the path should change from yellow to white, and it should no longer say that it is missing. If you have two separate toggle animations (One for toggle on, one for toggle off) repeat the process for the other.
 
 
Then you can simply delete the duplicated avatar (The animation changes will save and carry over to your original avatar) and re-enable your original avatar.
 
 
Your glasses should now be interactable and the existing toggles should still work! Please comment below if you are having troubles with this process. I’m by no means a Unity expert but I can try my best to help.
 
 

Written by baid

 
 
Hope you enjoy the Guide about VRChat – How to Make Avatar Interactable with Phys Bones in Unity, if you think we should add extra information or forget something, please let us know via comment below, and we will do our best to fix or update as soon as possible!
 
 


Be the first to comment

Leave a Reply

Your email address will not be published.


*