Animation doesn't play "No animation in cache."

Godot 4.4 animation

Hello,

I Needed an animation where i didn’t know some position till runtime , so i figured i can build animation from code and its playing fine
Once i create animation from code i cannot play any other animation i keep getting “No animation in cache.
No animation in cache.
No animation in cache.
No animation in cache.
No animation in cache.
No animation in cache.
No animation in cache.
No animation in cache.
No animation in cache.”

Bellow is the code :slight_smile:

  animationPlayer.SpeedScale = 1;
  animationPlayer.RootNode = GetPath();

  AnimationLibrary aniLib = new AnimationLibrary();
 

  var turnAnimation = new Animation()
  {
      Length = 0.4f,
      LoopMode = Animation.LoopModeEnum.None
  };
  
 //
  int positionTrack = turnAnimation.AddTrack(Animation.TrackType.Value);
  turnAnimation.TrackSetPath(positionTrack, ".:position");
  int rotationTrack = turnAnimation.AddTrack(Animation.TrackType.Value);
  turnAnimation.TrackSetPath(rotationTrack, ".:rotation");
  
  for (int i = 0; i <= CardDealSpeed; i++)
  {
     


      float moveWeight=1f / CardDealSpeed *i;
      var positionTmp =initialPosition.Lerp(targetPosition, moveWeight);
      //var positionTmp =initialPosition.Lerp(targetPosition
      if (i < Math.Ceiling((decimal)CardDealSpeed / 2))
      {
          
          positionTmp = new Vector3(positionTmp.X, positionTmp.Y + (0.1f * i), positionTmp.Z);
      }
      else 
      {
          positionTmp = new Vector3(positionTmp.X, positionTmp.Y + (0.1f * (CardDealSpeed-i)), positionTmp.Z);
      }

     


      turnAnimation.TrackInsertKey(positionTrack, i * 0.1f, positionTmp);
      turnAnimation.TrackInsertKey(rotationTrack, i * 0.1f, new Vector3(-2*i,0,0));
     
  }
  
  

  var animlibs = animationPlayer.GetAnimationLibraryList();
  var exist = animlibs.FirstOrDefault(x => x == "Procedural");
  if (exist == null)
  {
      aniLib.AddAnimation("DealCard", turnAnimation);
      animationPlayer.AddAnimationLibrary("Procedural", aniLib);

  }
  else
  {
      var proceduralAnimLib = animationPlayer.GetAnimationLibrary(exist);
      proceduralAnimLib.AddAnimation("DealCard", turnAnimation);
      

  }

It doesnt matter if i add it from editor or code the error is the same .

Question

Any help would be greatly valued

How are you playing the animation? At a glance I don’t see anything wrong with the code.

animationPlayer.Queue(“Procedural/DealCard”);
animationPlayer.Queue(“Procedural/Jump”);

Are you doing that before or after generating the animations?

If you are doing it before then the first call to queue() will try to play the animation which does not exists.

If you are doing that after then I’m not sure where the problem can be. Maybe open an issue if there isn’t one already open.