How to apply custom animation
Let's learn how to import external animation files and apply them to ZEPETO characters.
Access the site where you want to download animation. This guide is an example of using the Mixamo site.
📘 Mixamo
Click the desired humanoid animation.
Download the animation and select the "FBX for Unity (.fbx)" option.
Drag and drop the downloaded file to the Unity Project panel.
Click the Rig tab and change the Animation Type to Humanoid.
❗️ Caution
Without the humanoid setting, it will not be compatible with the ZEPETO character. Make sure to set it up.
Change the Animation > Motion > Root Motion Node option to <Root Transform> to make your character's animation smoother and more realistic.
📘 Unity Selecting a Root Motion Node
Clone an animator object associated with an animator variable in the ZepetoPlayers component inspector.
- File path : Packages/zepeto.character.controller/Runtime/_Resources/AnimatorController/ZepetoAnimatorV2.controller
- Drag the animator into the Assets folder.
After copying, rename it to ZepetoAnimatorV2_Custom.
Click Hierarchy > ZEPETO > ZepetoPlayers to create it, and drag a copy of the animator you created in the Animation Controller field of the ZepetoPlayers component.
Double-click ZepetoAnimatorV2_Custom to open the animator tab.
Drag and drop the new animation into the animator to create an animation state.
Right-click the animation state you created, and then click Make Transition to create a transition that returns to the Idle state.
Let's create an example of how to play an animation when you click a button.
Add Hierachy > UI > Button.
- Create a Hierarchy > Create Empty Object and rename it to CharacterController.
- Create Project > Create > ZEPETO > TypeScript and rename it to CharacterController.
- Write a sample script as follows:
- The flow of the script is as follows:
- Start()
- Adds a listener to playCustomAnimationButton that play animation when clicked.
- Calls the ZepetoPlayers.instance.CreatePlayerWithUserId() function to create a local player.
- Get the animator component of the local player and stores it in the localPlayerAnimator variable.
4. Attach the CharacterController script to the CharacterController object.
5. Assign Custom Animation Clip, Play Custom Animation Button from the inspector.
- Assign an animation clip that is set to Custom Animation Clip.
Drag and assign the button to the Play Custom Animation Button.
6. Play and click the button to play the animation.
👍 If you use a custom character other than a ZEPETO character,
you can apply the ZEPETO animation if it is a humanoid character.