Search Unity

Question Is there any way to replace animation clip in a AnimationClipPlayable?

Discussion in 'Animation' started by silver_gp, Oct 9, 2021.

  1. silver_gp

    silver_gp

    Joined:
    May 11, 2015
    Posts:
    10
    For example, I have 100 characters each of that has an animator attached to it. I want to play an animation on these 100 characters concurrently. So I load one animation and create the AnimationClipPlayable and then connect it to the graph for each character. I find framerate drops immediately. After profiling, I find that the connection to the graphs for these 100 characters takes a lot of time because the animators rebuild the internal data which costs a lot of time for these 100 characters.
    When I am profiling it, I find that in the animator's animation graph, the animations are not all connected to the graph.
    upload_2021-10-9_14-57-14.png
    This is the screenshot of the animator from Animation Graph Visualizer. If the character is walking we can see that the animations are all set in the AnimationClipPlayables.
    upload_2021-10-9_15-0-7.png
    If the character is not moving, I can see that the animations are removed from the AnimationClipPlayables. But these playables are still connected in the graph.
    Here (无动画) means it is an empty AnimationClipPlayable. So I wonder is there a way to remove and replace an animation clip from AnimationClipPlayable? If I can do that, I don't have to frequently connect new playables to the graph.
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    Animator Controllers are probably using something internal that we don't have access to because I've never seen a method to do that and it doesn't let you construct a clip playable with a null clip.
     
  3. silver_gp

    silver_gp

    Joined:
    May 11, 2015
    Posts:
    10
    Alright, thank you for replying.