CREATE YOUR WORLD
Players & Characters: Advanced
How to apply custom animation
11min
let's learn how to import external animation files and apply them to zepeto characters step 1 setting up animation access the site where you want to download animation this guide is an example of using the mixamo site 📘 mixamo https //www mixamo com/ https //www mixamo com/ 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 https //docs unity3d com/560/documentation/manual/animationrootmotionnodeonimportedclips html https //docs unity3d com/560/documentation/manual/animationrootmotionnodeonimportedclips html step 2 setting the animator 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 step 3 example of using a custom animation file let's create an example of how to play an animation when you click a button step 3 1 setting the ui add hierachy > ui > button step 3 2 writing a script 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 import { zepetoscriptbehaviour } from 'zepeto script'; import { button } from 'unityengine ui'; import { animator, animationclip } from 'unityengine'; import { spawninfo, zepetoplayers, localplayer, zepetocharacter } from 'zepeto character controller'; import { worldservice } from 'zepeto world'; export default class charactercontroller extends zepetoscriptbehaviour { public customanimationclip animationclip; public playcustomanimationbutton button; private localplayeranimator animator; start() { this playcustomanimationbutton onclick addlistener(() => { this localplayeranimator play(this customanimationclip name); }) zepetoplayers instance createplayerwithuserid(worldservice userid, new spawninfo(), true); zepetoplayers instance onaddedlocalplayer addlistener(() => { const player localplayer = zepetoplayers instance localplayer; this localplayeranimator = player zepetoplayer character getcomponentinchildren\<animator>(); }); } } 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