Search Unity

Renaming/moving child game objects breaks AnimationClips!

Discussion in 'Editor & General Support' started by johot, Aug 24, 2011.

Thread Status:
Not open for further replies.
  1. johot

    johot

    Joined:
    Apr 11, 2011
    Posts:
    201
    We just started working with the Unity animation system, it's good but it has many strange quirks. The problem we are having now is that we have a game object that contains multiple body parts (this is a 2D game). Now if we add the Animation component to the root object and start animating everything is working fine. However, as soon as we rename a child object the animation curves for that child object gets cleared out. Renaming the object back fixes this and they return, so it seems the animations for the child game objects are stored by name in the AnimationClip file. Also the same thing happens if we change the hierarchy for the child game objects.

    This is really bad I think, is there some way you can copy the curves from one game object to another or move them to a different game object? If we need to change the name or structure of our child game objects we could potentially loose hours of animation work.

    Anyone got a solution for this?
     
  2. ClintKilmer

    ClintKilmer

    Joined:
    Sep 3, 2014
    Posts:
    1
    Sorry to necro this post, but this really needs to be addressed.
     
    tonytopper and Eluem like this.
  3. blaher

    blaher

    Joined:
    Oct 21, 2013
    Posts:
    80
    I just ran into this issue, big issue! I spent hours animating a bone tree (30+ bones) and decided to rename things for cleanup from auto gen'd bone IDs only to find the animation is now completely broken.... grrr
     
    tonytopper and Eluem like this.
  4. blaher

    blaher

    Joined:
    Oct 21, 2013
    Posts:
    80
    To show how bad this issue can bite you, take a look at this bone chain and animation:

    animation window:


    It seemed like a great idea to rename all those bones to something like BodyBone1/2/3 or TentacleBone1/2/3 etc. after renaming the animation is not associated w the object anymore and worse, no idea which UniBone_1231283 goes to which bone I renamed so no way to go backwards. I had long finished renaming and doing other stuff in the project so couldn't even Ctrl-Z it :(
     
    Eluem likes this.
  5. Galactic_Muffin

    Galactic_Muffin

    Joined:
    Aug 14, 2013
    Posts:
    67
    Unity please fix this. it's sad to see so many people running into this problem and nobody has any answers. This is a problem that is clearly not addressed. For such a basic functionality too. im tired of editing the animation files in a text editor every time I want to rename gameobjects...
     
  6. codeage

    codeage

    Joined:
    Feb 7, 2015
    Posts:
    14
    After changing the name of a GameObject in the Hierarchy window, you can click the GameObject in the Animation window and rename it to make them identical.

    1. After renaming CameraController to CameraController1 in the Hierarchy window, the animation is lost (marked as yellow).
    upload_2015-4-4_12-37-6.png

    2. In the Animation window, click the same GameObject and rename it to CameraController1.
    upload_2015-4-4_12-31-45.png

    3. Now the animation works again.
    upload_2015-4-4_12-38-36.png
     

    Attached Files:

  7. febix

    febix

    Joined:
    Jun 2, 2013
    Posts:
    12
    Thank you! It helped me a lot. :)
     
  8. TommySKD

    TommySKD

    Joined:
    Jul 23, 2014
    Posts:
    25
    codeage method doesn't work for me, even if you rename the object correctly in the animation window it still says it is missing.

    EDIT: oh it works actually!
     
    Last edited: Oct 18, 2018
  9. trialforce

    trialforce

    Joined:
    Apr 15, 2012
    Posts:
    22
    Don't work for me too!

    I really like Unity but make good 2d animation is really messy.

    I can't change sprite order in layer, i can't rename my gameobject.

    Please Unity, in this way the 2d animation it's not really usable.

    @Galactic_Muffin how you edit in a text editor, the file is binary for me, can you help me?

    Thanks!
     
    Last edited: Jun 20, 2015
  10. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,051
    Under editor preferences change the serialization option to force text.

    You can do find and replace to fix references, and even reorder the hiearchy as they contain the path to objects.

    The ability to edit structure in editor would be nice. But until they add it, the best approach is to use a bit of planning so you don't have to reorder. Or use empty objects as containers.
     
    Sangar-Zucchi likes this.
  11. trialforce

    trialforce

    Joined:
    Apr 15, 2012
    Posts:
    22
    It worked! Thanks a lot!

    Also, your game is very good, I played it in my Android tablet!
     
  12. Zaflis

    Zaflis

    Joined:
    May 26, 2014
    Posts:
    438
    Thanks, the solution works for some parts but not when renaming parent objects. Say you have 2 objects:
    Mob1Torso -> Mob1Arm
    and then you rename Mob1Torso to Torso. The animation for Mob1Arm is now broken and it can't be linked to the new Torso object.
     
    Sangar-Zucchi likes this.
  13. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,051
    Yea... That can happen, sometimes it can be fixed by renaming the path in anim file. But not always, I am not sure why. At some point within the last several versions of unity, something has changed or picked up a bug or two. Anims and/or the controller been becoming more unreliable and fragile.
     
  14. Th0re

    Th0re

    Joined:
    Sep 4, 2015
    Posts:
    39
    Had the same problem and was flailling around but found a solution from user khan-amil /thanks:
    http://forum.unity3d.com/threads/is-it-possible-to-rename-objects-that-are-animated.280622/

    The tool / solution
    https://github.com/s-m-k/Unity-Animation-Hierarchy-Editor/blob/master/AnimationHierarchyEditor.cs

    There seems to be a bug in the editor (unity-5.2.3). Check the following to reproduce (don't do this with your good animation, you reproduce a bug, even when you can fix it now):

    {1} Go to the animation window, click on one animated object, and hit F2 (or click twice to rename).
    {2} Now rename it to anything.
    {3} Object should turn yellow now and you see the path, an additional slash (/) was added.
    {4} Rename it back: you see there is now yet another slash, i.e. renaming always adds a slash
    {5} Since you cannot remove the wrong slashes by this method, your path is broken.

    Example: You have Alice/head. You rename "head" to "hat", now the path is "Alice//hat" and when you rename again it's "Alice///head", but you can't go back to "Alice/head". With the tool mentioned above you can conveniently correct the paths (and rename) to your heart's content.

    /first post. Since I found this post easier, I thought I add what I found.
     
  15. Eluem

    Eluem

    Joined:
    Apr 13, 2013
    Posts:
    57

    I discovered this as well and posted my discovery here: http://answers.unity3d.com/questions/1101465/change-animation-property-target.html

    You can work around this by editing the actual animation file to remove the slashes... however if you change the total length of the names, the file breaks. I wasn't able to figure out how to work around that except to manipulate it in the editor to make the length of the name I put in + however many glitch slashes adds up to my new name... but that can't work if you want a shorter name.


    I just don't get why this hasn't been fixed yet though. The issue should be fairly easy to fix. There's multiple options:
    1) fix the rename code so that it doesn't add an extra slash

    2) expose the full path in the editor so that we can manually enter it (this also allows for retargeting curves to similar objects with different parents)

    3) Make it so the animation system isn't oddly dependent on the length of the file so that we can manually edit these with text editors reliably. (then it would be easy enough to build an editor extension in unity to solve this)
     
  16. Eluem

    Eluem

    Joined:
    Apr 13, 2013
    Posts:
    57
    Even then, you can only edit the names to become bigger (unless you found a way around this? if you did, let me know.. I might try to create an editor extension to help us fix this problem.. it won't be as good as Unity just taking care of it the right way.. but it'll be something)
     
  17. Galactic_Muffin

    Galactic_Muffin

    Joined:
    Aug 14, 2013
    Posts:
    67
    Yes, I show a detailed step by step explanation of how to access and edit the animation files in a text editor at the bottom of this topic replies: http://forum.unity3d.com/threads/an...animation-wont-play-when.307886/#post-2003550

    But Ill also post it here:

    Typical rule of thumb when animating in unity, be very careful where unity creates or you create your animation controller on. if you start building your animation with the wrong controller, or have your controller on the wrong game object, you will not be able to move that controller on a different game object after you have made the animations. but if this does happen to you and you have made an elaborate animation that you would rather not redo, here is how you fix the problem:

    We will be editing the actual animation files so make sure you have your original animations duplicated so you have a backup:

    so we want to open these animation files in a notepad application but if you did that, you would most likely get a long list of binary, so to convert it to something we can actually read, just open up your editor settings and change Asset Serialization to "Force Text".


    Now we can go ahead and open these animation files in Notepad. once you have them open scroll down the animation file untill you find the "path" we want to replace the game object that the path is assigned to in this file with nothing. so do a find < Replace All and replace everywhere it says the first game object in your path to nothing (and remember to include the first / when replacing all). This will enable you to move your animator component to any game object parented to the objects you are animating:



    After you have completed this you may delete the original animation files and you can re-hook your new edited animation files into your animator and you can move your controller. :)
     
    Hallowed_, a436t4ataf and Eluem like this.
  18. pixi2

    pixi2

    Joined:
    Dec 22, 2013
    Posts:
    14
    I can't believe this issue is still open. It's incredible annoying and makes the whole animation-workflow borderline unusable. Throw in the inconsistent undo-behavior and the occasional update-glitches of the inspector (highlighting attributes red although they aren't animated) makes animating in unity a real pain.

    It keep wondering, if the people who patched this piece of **** together ever had to work with it for themselves. They should be forced to. This is one of the ugliest areas of unity, indeed.
     
  19. cupojoe

    cupojoe

    Joined:
    Apr 4, 2016
    Posts:
    1
    I know this is a very old thread, but I don't think things have changed a lot in this regard and finding this helped me (almost) to solve my reparenting problem.
    Here is what I did:
    1. Reparented object in Unity (in my case I added a root GameObject to it, but you could go from a flat structure to a "bone" hierarchy if you want to)
    2. In the Editor panel, changed the Asset Serialization to Force Text (Project Settings->Editor)
    3. Opened the .anim file (for each animation) in my case in Sublime Text but you can use plain text editor
    4. Applied Find and Replace All to the file changing "path: " by "path: Root/" (in my case, if you want to parent just the arms then you need to adjust your search query accordingly, or do it manually one property at a time. (Follow what @Galactic_Muffin said)
    5. And here is what did the trick for me: Open the animation you just edited in the Animation panel in Unity and move the the new object you added (in any frame, you are going to undo this anyway).
    The last step was what updated the new parenting so all the old rotations and translations would refresh and playback as intended.
    Hope this help someone trying to get around this issue!

    Note: this is specially useful if you have rotations in your animation
     
    Chambers88 likes this.
  20. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,773
    It would be nice if this were added as a feature to fix in the next version of Unity.

    Extremely annoying.

    Thx for tip workaround though! :)
     
    Last edited: Aug 1, 2016
  21. BizzTheGreat

    BizzTheGreat

    Joined:
    May 26, 2016
    Posts:
    1

    WOW! Just WOW!
    This tool was a real savior!


    I need to add some notes.

    Before I use your solution I managed to rename MOST of the rows just using F2, however there were two problems I couldn't overcome:
    1. I stuck with Alice///head problem (really annoying)
    2. renaming a sprite animation row is not possible (unity throws exception)
    head -> Container/head : Sprite Renderer.Enabled (this was easily updated using F2)
    head -> Container/head : Sprite (InvalidCastException: Cannot cast from source type to destination type)


    Then I used your solution and it gave me this exception Path [something] already exists in that animation!

    I think it's because I changed some rows before I use the tool, so I carefully commented line 320 (where it throws the exception) and everything worked out.

    Thank you :)
     
  22. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,773
    Wow. I've been working with Unity for 6 years, and I just now learned that F2 exists & is a superior method to renaming than "click-waiting". Thank you.

     
  23. thisismyspam

    thisismyspam

    Joined:
    Mar 23, 2014
    Posts:
    1
    funny that this is still an issue after 6 years... (not really)
     
  24. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    This hasn't been fixed yet? Why has no one filed a bug report in 6 years?
     
  25. NecrosDk

    NecrosDk

    Joined:
    Oct 5, 2012
    Posts:
    8
    I'm gonna necro this just in hope that it gets more attention because I just had to go through a lot of hassle of renaming lines of text files to fix these dependencies. There should REALLY be a solution for fixing animation dependencies when the hierarchy of your prefab is changed.
     
  26. Ali_V_Quest

    Ali_V_Quest

    Joined:
    Aug 2, 2015
    Posts:
    138
    Thank you - it works
     
  27. SirIntruder

    SirIntruder

    Joined:
    Aug 16, 2013
    Posts:
    49
    Sorry for necroing this.
    I have the same problem, and I am trying to solve it by renaming stuff in animation window like in codeage post, but it just doesn't work
    F2, Enter, tried to find something like right click->rename, no response
    I am on 2017.1 on Windows.
    Clip was not imported, I just created it in the editor.
    Any ideas?

    Update: restarted Unity, now it works. Who knows. It would be nice if "Rename" was available in the right click context menu, you only get "Remove property"
     
    Last edited: Sep 8, 2017
  28. SibochCZ

    SibochCZ

    Joined:
    Apr 29, 2017
    Posts:
    3
    Thanks, it works!
     
  29. BugFuxker

    BugFuxker

    Joined:
    Jun 20, 2016
    Posts:
    1
    Did you try to rename the bone in Blender yet? (or may be other modeling software) it work for me.
     
  30. LazyKnight

    LazyKnight

    Joined:
    Jul 28, 2017
    Posts:
    7
    This awesome bug still works in 2017.2f1
    I have no words to say.

    Did 2018 fixed this?
     
  31. LazyKnight

    LazyKnight

    Joined:
    Jul 28, 2017
    Posts:
    7
    One of the solution, ugly but work, for those who didn't change so many structures or the nearly top-level node in their animated GameObject:

    1. enter animation record mode.
    2. find your [renamed] or [moved] GameObect, change the property you animated before.
    3. select the original (missing) property line, copy all of the frames. (you could select the whole frames in animation editor and copy them)
    4. go to the new property line, past them, it works.

    Yet this solution really doesn't help a lot, if you're developing some tiny component, this may work fine.
    Hope there is a better animation editor here.
     
    unnanego likes this.
  32. unnanego

    unnanego

    Joined:
    May 8, 2018
    Posts:
    199
    2019...
     
    a436t4ataf and CarterG81 like this.
  33. unnanego

    unnanego

    Joined:
    May 8, 2018
    Posts:
    199
    Well, now at least you can rename positions in the Animation window. If you made an animation and then put the animated element as a child, you can add the name of the parent in the animation window divided by / For example: Game Object/Child Game Object
     
    a436t4ataf and Kyodan like this.
  34. josephquested

    josephquested

    Joined:
    Oct 21, 2015
    Posts:
    5
    this S*** still sucks.
     
    a436t4ataf, unnanego and CarterG81 like this.
  35. threesixty_reality

    threesixty_reality

    Joined:
    Oct 10, 2018
    Posts:
    1
    Found a good solution for this:

    - if your object is in the main hierarchy the F2 renaming method will work
    - if your object is nested in the hierarchy try: F2 then renaming this way: parent/child, i.e use the slash to indicate the position in the hierarchy. It worked for me!
     
    ben_unity982 and unnanego like this.
  36. DanT_BK

    DanT_BK

    Joined:
    May 16, 2017
    Posts:
    2
  37. daveseidman1

    daveseidman1

    Joined:
    Jun 11, 2019
    Posts:
    2
  38. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    2020...

    (LMAO this is why I hated Mecanim when it came out - didn't solve the problems that already existed, and only added new ones. Got to second the poster who said "whoever wrote this should be forced to use it [to make an actual game]". It's so genuinely terrible and unmaintainable. Artists/Animators suffer in silence every day on their projects, not realising that some relatively simple better code/design on Unity's part would make their lives many times better, and projects delivered faster. Fingers crossed someone releases an asset soon on the store that replaces the AnimationWindow with something fit for purpose! :))
     
    CarterG81 and unnanego like this.
  39. JohnTomorrow

    JohnTomorrow

    Joined:
    Apr 19, 2013
    Posts:
    135
    Just ran into this an edited the generated text by hand. Was able to fix it and not lose hours of work. Still ridiculous the editor is this fragile.
     
    CarterG81 likes this.
  40. HampusSVRVIVE

    HampusSVRVIVE

    Joined:
    Oct 3, 2016
    Posts:
    3
    This could've been a good fix if I didn't use blendshapes. Can tell you that there's no way to fix blendshapes being in a different hierarchy.
     
  41. datagreed

    datagreed

    Joined:
    Sep 17, 2018
    Posts:
    42
    Renaming by clicking or pressing enter/F2 seems to stopped working in 2019.4.5f1 on Mac - cannot rename from Animation window anymore :(
     
  42. Dielji

    Dielji

    Joined:
    Oct 16, 2016
    Posts:
    4
    This is still a problem 9 years later. Best I can come up with is to select the hierarchy I changed and add the properties I moved/renamed to the dopesheet, then select the animation clip directly and copy/paste the keyframes from the old property. It seems to be important to select the character first, then the clip second: you need the character selected for the clip to find the changed properties, but you have to select the clip directly to stop it from zeroing out the properties that are missing. It's really janky and tedious, and for smaller animations it would probably be easier to just redo the animation from scratch.
     
    CarterG81 likes this.
  43. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    211
    Really annoying that one cannot use Animation to do UI, if transforms change parent as part of the UI process..
     
    CarterG81 likes this.
  44. litebox

    litebox

    Joined:
    Aug 29, 2011
    Posts:
    158
    You made my day! I straggle from this issue many times but don't realise I can rename the animated property haha!
     
Thread Status:
Not open for further replies.