Search code examples
androidandroid-animationarcoresceneform

AnimatorSet - Getting Error: Only one ModelAnimator may play on a ModelRenderable at a time


I'm trying to play multiple animations one after another, but I can't seem to get it to work. It's giving me the error:

Only one ModelAnimator may play on a ModelRenderable at a time

I've followed the instructions from this Stackoverflow Answer:

https://stackoverflow.com/a/55684795/11110509

private void animateModel(ModelRenderable modelRenderable) {

        AnimationData danceData = modelRenderable.getAnimationData("Armature|Pecking.002");
        ModelAnimator modelAnimator = new ModelAnimator(danceData, modelRenderable);

        AnimationData danceData2 = modelRenderable.getAnimationData("Armature|Walking");
        ModelAnimator modelAnimator2 = new ModelAnimator(danceData2, modelRenderable);


        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.play(modelAnimator).before(modelAnimator2);
        animatorSet.start();


    }

What am I doing incorrectly?


Solution

  • As far as I know, since 1.16, ModelAnimator and ModelRenderable.getAnimationData are not supported anymore.

    If you must use version less than 1.16,

       List<Animator> animatorList = new ArrayList();
       animatorList.add(modelAnimator);
       animatorList.add(modelAnimator2);
       animatorSet.playSequentially(animatorList);
       animatorSet.start();
    

    You can do like above. I haven't tested the code since i am using sceneform 1.16.