google-ar / sceneform-android-sdk

Sceneform SDK for Android
https://developers.google.com/sceneform/develop/
Apache License 2.0
1.23k stars 603 forks source link

Didn't able to play the animations sequentially #656

Open maherahmedraza opened 5 years ago

maherahmedraza commented 5 years ago

private void onPlayAnimation(View unusedView) { if (animator == null || !animator.isRunning()) {

  AnimationData data = andyRenderable.getAnimationData(0);
 // Log.d(TAG, "onPlayAnimation: "+data.getName());
  //nextAnimation = (nextAnimation + 1) % andyRenderable.getAnimationDataCount();
  animator = new ModelAnimator(data, andyRenderable);

  AnimationData data1 = andyRenderable.getAnimationData(1);
   animator1 = new ModelAnimator(data1, andyRenderable);

  AnimationData data2 = andyRenderable.getAnimationData(2);
   animator2 = new ModelAnimator(data2, andyRenderable);

   List<Animator> anims = Arrays.asList(animator,animator1,animator2);
    AnimatorSet s = new AnimatorSet();
   s.playSequentially(anims);

  Toast toast = Toast.makeText(this, data.getName(), Toast.LENGTH_SHORT);
  Log.d(
      TAG,
      String.format(
          "Starting animation %s - %d ms long", data.getName(), data.getDurationMs()));
  toast.setGravity(Gravity.CENTER, 0, 0);
  toast.show();
}

} I think there is a problem with AnimatorSet because its is not playing the animations sequentially. Please can you provide the solution for how to fix this? I need this to run with playSequentially function.

maherahmedraza commented 5 years ago

It throws error "Cannot play more than one ModelAnimtaor on ModelRenderers at a one time".