banner



How To Open Model Animator In Unity

Let's talk about avatars!!

Avatars are mostly used to visualize characters in a 3D game/feel. More often than not, having uncanny avatars in your game can make the users uncomfortable. Now that the metaverse is gaining popularity, avatars are condign more significant.  And, having bad avatars can ruin any VR experience likewise.

Having looked at diverse avatar creating platforms like Spatial, avatarsdk, IMVU etc. One that stood out was Set Player Me. The best function about this is y'all can not only create avatars, but you tin can also download the models and animation and utilize it in your project. And so, this blog volition be focusing on creating your own avatar using Ready Role player Me and integrating it into Unity. Later we'll tell how y'all tin can easily add rig your avatar using Animation Rigging and IK.

i. Creating Your Avatar

It'due south actually elementary to create an avatar in Fix Actor Me.

  • Head over to the Ready Player Me website and click on Create avatar.
  • And so, you need to choose your trunk blazon 🚻
  • At present you volition have 2 options, either to upload your selfie or to continue with a default avatar.
  • Later on yous chose one of the two options, you can customize your avatar!
    • You tin choose the clothing πŸ‘• from a selected range.
    • Yous can change your facial features like pare colour 🎨, cheekbone, hairstyle πŸ’‡, eyes πŸ‘€, etc.
    • Accessories similar numberless πŸ›️, hats 🎩, caps πŸŽ“, glasses πŸ•Ά️ and more.

    Ready Player Me

  • Click on Enter Hub and your avatar is now set up.
  • You can claim your avatar by signing in.

    Ready player me Avatar

Wasn't that actually simple? Importing that into Unity is also every bit simple every bit that! So let's see how it'southward washed.

two. Importing the Avatar into Unity

To import the avatar into Unity you need to download the Unity Avatar SDK provided by Ready Player Me. To download it:

  • Open up the Ready Actor Me documentation, so click on Unity Avatar SDK Download. This volition open a new web page.
  • Under the Latest release department, click on Download the latest version of the Unity SDK. This will open a Google Drive page.
  • Correct-click on Ready Player Me_v1.7.0.unitypackage → And then, click on Download → Save it in a path of your option.

    Ready player me SDK

One time you have the SDK downloaded, create a new Unity projection or open an existing i and let's see how we tin can go the Avatar into Unity.

Notation: Make certain you are using Unity version 2019LTS and to a higher place
  • To import the SDK into Unity, you can either drag and drop it into the scene or you tin import the packet from the tiptop Unity Editor toolbar via AssetsImport PackageCustom Packet → Then from the file explorer select the ReadyPlayerMe Unity package.
  • A window volition popular upwardly. ⚠️ Brand certain you uncheck Newtonsoft Json before hitting Import to first importing the package into the project.

    Import SDK

  • Get to the Prepare Role player Me website and navigate to the My Avatars tab. Click on the iii dots at the top correct corner of the Avatar and click on Copy .glb URL.

    Import SDK

  • Go back to Unity and in the Avatar Loader window paste the copied .glb URL in the URL or Short Cord field and click on Load Avatar.

    Load Avatar

That was uncomplicated, correct? Now that nosotros take an Avatar with united states of america, nosotros can utilise the XR Interaction Toolkit and Blitheness Rigging packages to add VR components and inverse kinematics to the Avatar. Inverse kinematics is nothing only adding movement to other parts by moving one of the connected parts. Thus, enabling the states to utilize the avatar in VR.

3. Setting up Unity for VR

In this section, we volition run across how nosotros can set upwards Unity for VR and convert this regular avatar into an avatar that can exist used in the metaverse! Nosotros will exist making use of the XR Interaction Toolkit and the XROrigin Unity package that's custom made by us.

Note: If you already know how to set your project for VR or if you already have your ain XROrigin, and then please feel free to jump to the next department.
  • In Unity, click on WindowsBundle Manager → select the setting icon ⚙️ → Advanced Project Setting → Check the box for Enable Preview Packages and select I understand. It'southward just a warning that it'due south a preview package and not yet released and then it could potentially accept bugs.

  • To import the XR Interaction Toolkit:

    • Open the Package Manager → select Unity Registry from the drop-down → search for "XR Interaction Toolkit" or scroll downwards to find it.
    • Select that parcel and make sure the version is 2.0.0-pre.6 → click on Install.
    • Later installing, a window will pop upwardly asking you to restart Unity, click on Yes to continue. Brand sure you have saved the scene and the projection.

    XR Interaction Toolkit

  • Later Unity restarts, navigate dorsum to XR Interaction Toolkit parcel in the Bundle Manager. Import Default Input Activeness and XR Device Simulator.

    XR Simulator

  • Download the XROrigin packet from here → Import the package from the summit Unity Editor toolbar via AssetsImport PackageCustom Bundle → Then from the file explorer select the XROrigin Unity packet.

    Importing XR Origin

  • Delete the Main Camera πŸŽ₯.

  • In the projection folder, navigate to FeaturesXROriginPrefabs. Drag and drop the XROrigin into the scene.

    XR Origin

4. Setting up the Avatar and Animation Rigging

In this department, we'll gear up up the avatar and use the Animation Rigging package to add together inverse kinematics to it to have a realistic body movement in VR.

  • In Unity, click on WindowsPackage Managing director → search for Blitheness Rigging and install it.

    Animation Rigging

  • From the hierarchy, select the Avatar GameObject and remove the Controller and Avatar from the Animator component. → Add Rig Builder and Bone Renderer Components to it.

    Rig builder

  • Click on the Avatar GameObject and lock πŸ”’ the Inspector window → Press and hold the Alt key and click on the Avatar to open all its children → Select the Hips Game object, scroll downward and select the concluding kid GameObject while holding the Shift primal → Drag and drop it into the Transforms field of the Bone Renderer component. With that, y'all will be able to encounter the bones 🦴 of the avatar.

    Bone renderer

  • Click on the Avatar GameObject and from the toolbar select Animation Rigging → click on Rig Setup, this will create a Rig every bit a kid of the avatar → remove the empty layer from the Rig Builder component → unlock πŸ”“the Inspector window → select the Rig1 GameObject and rename it as VRRig.

    VR rig

  • Select the VRRig GameObject,

    • Create an empty GameObject as a child and name it equally IKRightArm → create two GameObjects every bit a kid of this and proper name them as Target and Hint respectively.
    • Then, select the IKRightArm GameObject, add Two Bone IK Constraint component and lock πŸ”’ the Inspector window → from the Scene view select the right arm and, drag and drop the GameObject into the Root field of the 2 Bone IK Constraint component → similarly, select and, elevate and drop the right forearm and right hand into the Mid and Tip field respectively. Finally, drag and drop the Target and the Hint GameObjects into the corresponding Source Objects field.

    Right IK

  • Select the Target GameObject and while holding the Shift key select the right hand from the Scene view → from the toolbar select Animation Rigging → click on Marshal transform.
    Similarly, select the Hint GameObject and while holding the Shift key select the right forearm from the Scene view and marshal their transforms equally well. And so, move the Hint GameObject slight back.

    Align Transform

  • Duplicate the IKRightArm GameObject and name it as IKLeftArm → Drag and driblet the LeftArm, LeftForeArm and LeftHand GameObjects into the Root, Mid and Tip fields of the Ii Bone IK Constraint component respectively → Align the Target GameObject with the left manus and Hint GameObject with the left forearm. Also, move the Hint GameObject slightly back (aforementioned value every bit the Hint GameObject of IKRightArm).

    Left IK

  • Information technology'southward time to test information technology! Hit the Play ▶️ push → select both the targets and move them effectually in the scene view. If they are moving with the elbow as the hinge so yous have successfully set the arms. If not feel free to go through all the steps above and brand certain everything is ready correctly. Go out the Play mode and let's move on to the last step in this section.

    Testing VR

  • Select the VRRig Game object, create an empty GameObject and proper noun it IKHead → add the Multi-Parent Constraint component and lock πŸ”’ the Inspector window → from the Scene view select the head and, drag and drop the GameObject into the Constrained Object field → elevate and drop the Head GameObject into to the Source Objects field. Finally, align the IKHead GameObject to the Head GameObject.

    Head IK

That completes setting up the Avatar with an animation rig. Side by side, was desire the Avatar's head and hands to follow the XROrigin's photographic camera and the hands respectively. So, permit'south move on to the next section.

5. Scripting and Avatar configuration

Permit's write a script that will allow u.s. to move the avatar along with the XROrigin. The script will not work direct, we need to brand a few adjustments to the avatar's transform later in the Unity editor so that it matches the XROrigin.

  • In the Project window, create a new C# script, name information technology as AvatarController and copy the following code. In the code, nosotros are using Tardily Update to make certain we have captured the motion that might have occurred in the Update.

                  using UnityEngine;   [Organisation.Serializable] public form MapTransform {     public Transform vrTarget;     public Transform IKTarget;     public Vector3 trackingPositionOffset;     public Vector3 trackingRotationOffset;      public void MapVRAvatar()     {         IKTarget.position = vrTarget.TransformPoint(trackingPositionOffset);         IKTarget.rotation = vrTarget.rotation * Quaternion.Euler(trackingRotationOffset);     } }  public form AvatarController : MonoBehaviour {     [SerializeField] private MapTransform head;     [SerializeField] individual MapTransform leftHand;     [SerializeField] private MapTransform rightHand;      [SerializeField] private float turnSmoothness;      [SerializeField] private Transform IKHead;      [SerializeField] private Vector3 headBodyOffset;      private void LateUpdate()     {         transform.position = IKHead.position + headBodyOffset;         transform.frontwards = Vector3.Lerp(transform.forward, Vector3.ProjectOnPlane(IKHead.frontward, Vector3.upward).normalized, Time.deltaTime * turnSmoothness); ;         head.MapVRAvatar();         leftHand.MapVRAvatar();         rightHand.MapVRAvatar();     } }                          
  • Add this script to the avatar → Drag and drop the MainCamera, LeftBaseController and RightBaseController GameObjects into the VRTarget of Head, Left Manus and Right Hand fields respectively → Elevate and drib the IKHead, Targets of IKRightArm and IKLeftArm GameObjects into the IKTarget of Head, Left Paw and Right Hand fields respectively → Drag and drop the IKHead GameObject into the IKHead field at the bottom.

    Avatar controller

  • To align the transforms together, you lot need to hitting Play ▶️ and apply the XROrigin's manus as a reference to correctly orient the Avatar'south hands. I made apply of the XRSimulator for the initial orientation and later played it on my Vive to make last adjustments. Feel free to utilize the same values to outset with and so you can tweak information technology as per your requirement.

    VR values

    Controller values

  • You can run across that the avatars' caput is blocking the camera vision. To correct that nosotros'll create a new layer called Ignore and assign it to the avatar's optics, head, pilus, glasses and teeth. Then, we will uncheck the Ignore layer from the Photographic camera'southward Culling Mask field. Culling Mask is used to render parts of the Scene selectively, since we are unchecking Ignore layer, that camera volition not render GameObjects with the Ignore layer.

    Culling Mask

  • You tin can create a mirror to see yourself in VR by making apply of a Quad, a Camera and a Render Texture.

    Note: You tin can refer to Department 2.4 of the Selfie Stick blog to know how to create a Render Texture and display the Camera's output on a Quad.>

    Render Texture

  • Finally, disable the XROigin'southward paw prefabs by setting the Model Prefab field of the XR Controller (Action-based) Component of the Left and Right base controller GameObjects to None.

    VR hands

  • Hitting Play ▶️ and exam it in VR.

    Play testing

With that, nosotros accept successfully rigged our Avatar for VR.

Conclusion

In this blog mail service, nosotros've learned how to create an avatar, import it to Unity and rig our Prepare Player Me avatar for VR.

So, what to do next? Well, nosotros rigged simply the upper body but you can go further and rig the lower body also (Possibly something that we volition cover in the next blog post). Also, the hands can exist animated when the grip and trigger buttons are pressed.

See you next time!

____________________

Thank you

Thanks for reading this web log mail service. 🧑 If you are interested in creating your ain AR and VR apps, you can learn more nigh it here on immersive insiders. Also, if you lot have any questions, don't hesitate to reach out! We're always happy to assistance.

Source: https://blog.immersive-insiders.com/animate-avatar-for-vr-in-unity/

Posted by: jamesexther.blogspot.com

0 Response to "How To Open Model Animator In Unity"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel