After you know how to create Animation in Roblox that we have explain in the previous article, now you surely want to know how to use it. You want to know how to enter the animation into a game. We are going to tell you several things about how to use it.
You are able to use multiple animations in Roblox. It can be used for the same action. If the multiple animations exist for a character state, the Animate script will select randomly which one to play even though the outcome is able to be influenced by altering the weight of animation NumberValue. You are able to check the script in the Developer Roblox website.
If you want to use custom animations built through the Animation Editor for default character animations, there are some points that you need to know. First, you have to name the final keyframe in the custom animation End. It will trigger the animation script to pick the next animation to play. Second, the script of animation which is built into Roblox characters handles animation looping automatically. So, it is better for you to disable the Loop option in the animation editor before you publish the animation. If you leave looping on, multiple animations will not be able to work for the character state which is given.
Now, how to play animations directly? If you use custom animations built with the Animation Editor, you will often have to play an animation directly from inside a script, for example when the player hits a certain key, picks up a special item and so on. If you want to apply an animation to a player character, it needs to contain a Humanoid object to load the animation through Humanoid:LoadAnimation() and also part named HumanoidRootPart.
How about using animations for NPCs? It is the same as using them for player characters, but it is not essential that the NPC contains a Humanoid object. If an NOC does not contain a Humanoid, you need to load or play the animation from an AnimationController object parented to the NPC. If you want to use animations for NPCs, you have to obey note guidelines. Here they are.
- First, NPC animations should be controlled by a Script not a LocalScript.
- Second, you are not able to control animations through both a Humanoid and AnimationController on the similar rig.
By the way, after you make an animation, you do not know where you can find the animation ID. This thing is important to know because if you want to change a default animation, you will have to locate the asset ID. How to locate the asset ID of an animation? If you want to find the ID of animations in the Avatar Animations section of the catalog, you can find a specific animation and copy its ID from the URL in your browser. If you want to find an asset ID of animation that you have created and exported through the Animation Editor, you are able to locate the animation in the Animations section of the Create page and then copy its ID from the URL in your browser.