Animations don't work at runtime
See original GitHub issueHello, I tried to import .glb character with animation, but it doesnt seem to work. It plays fine when I load it at runtime in the editor. But when I build it, the character is not animated. I tried it on Android, iOS and MacOS and neither of these worked. Only in the editor. Do you have a clue, what could I do wrong?
Thanks in advance for your response.
Here’s the code I use:
// Create new mesh.
AnimationClip[] animationClips;
GameObject result = Importer.LoadFromFile(itemFileInfo.FullName, new ImportSettings(), out animationClips);
// Setup animation, if there is any.
if (animationClips.Length > 0)
{
Animator animatorComponent = result.gameObject.AddComponent<Animator>();
AnimatorOverrideController gltfAnimatorOverride = new AnimatorOverrideController(gltfAnimator);
for (int i = 0; i < animationClips.Length; ++i)
{
gltfAnimatorOverride["test"] = animationClips[i];
}
animatorComponent.runtimeAnimatorController = gltfAnimatorOverride;
}
I’m also attaching the .glb file: mixamo.glb.zip
Issue Analytics
- State:
- Created 3 years ago
- Comments:9
Top Results From Across the Web
Runtime instantiated prefabs not playing animations
Ok, nevermind. Seems to have been due to the default animation culling type, the animations will not play if "Based on Renderers" is...
Read more >Animator not animating a runtime instantiated child (UNITY)
1 Answer 1 ... With current animator settings, this behavior is normal. You need to change your current animator using Any State section...
Read more >android - Add animation at run time
I want to animate my AnimatedVectorDrawable at runtime without using .xml files. Actually I'm using .xml files same way as documentation's ...
Read more >C Runtime animation mix doesn't work
If you have multiple animations, eg A -> B -> C then yes, it will apply A and B and then C and...
Read more >Animation Engine - Runtime Changes and Fixes
So, I've tried editing the animation track's priority via scripts, and it doesn't work. Editing from the server does nothing.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Had the same issue on Android. I was getting error. “can’t use animatioclip set curve at runtime on non legacy animation clips”
Solved it by setting useLegacyClips to true on importSettings.
The Playables API doesn’t support legacy animation clips and GLTFUtility was failing to import non legacy clips at runtime, Unity was throwing this error: “Can’t use AnimationClip::SetCurve at Runtime on non Legacy AnimationClips”.
So now I’m using the the legacy Animation system, tested and working on iOS.