Search Unity

Is it possible to rename objects that are animated

Discussion in 'Animation' started by CarpetHead, Nov 17, 2014.

  1. CarpetHead

    CarpetHead

    Joined:
    Nov 22, 2013
    Posts:
    20
  2. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Animation binding is named based, which mean that your animation curve store internally the name of the properties to animated and the whole path to find it, by example "Hips/LeftUpLeg/LeftLeg/LeftFoot"

    If your clip are imported, then simply go back to your authoring tools(3ds max/maya, etc...) rename your object and import back your animation.

    If your clip was created in unity with animation window, if you rename your object hierarchy you will lose the binding between your animation curve and the animated properties. The curve still exist in your clip but should appear in yellow to show you that the target properties is missing. You can still fix it by writing a script that goes through all your clip curves and fix the path.
    see http://docs.unity3d.com/ScriptReference/AnimationUtility.GetAllCurves.html
     
    Mehrdad995 and Sangar-Zucchi like this.
  3. Grafos

    Grafos

    Joined:
    Aug 30, 2011
    Posts:
    231
    Isn't this extremely counter-intuitive? Can't you add a functionality to set a new path for the animation curve?
     
  4. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    The API already allow you to do this by script.

    Also there is already some script available on the asset store that can do this with some nice UI.
     
  5. skullthug

    skullthug

    Joined:
    Oct 16, 2011
    Posts:
    202
    What's the name of this script? Link?
     
    sirshelley and awsapps like this.
  6. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    I don't remember exactly but I know it does exist because the creator of this script did ask me a few question a long time ago.
     
  7. skullthug

    skullthug

    Joined:
    Oct 16, 2011
    Posts:
    202
  8. khan-amil

    khan-amil

    Joined:
    Mar 29, 2012
    Posts:
    206
    Got this issue yet again, and found the tool @Mecanim.Dev was talking about :
    https://github.com/s-m-k/Unity-Animation-Hierarchy-Editor

    Still, people using the animation window don't necessary know how to code, so having it available by the API won't help them much..

    Now that there are tools to fix it, if it won't be integrated in the engine, you could at least put a more helpful description when a renaming is detected, pointing to an actual solution like this github.
     
  9. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Thanks for sharing the link Khan-amil.
     
    NymoBasepro and theANMATOR2b like this.
  10. RElam

    RElam

    Joined:
    Nov 16, 2009
    Posts:
    375
    This script is not a robust solution, as with rotation keyframes it will create keyframes for all time points, effectively destroying precisely created hand animations. The function used and API seem to imply this may intended behavior. Anyway, it really sucks that you can't rename objects you've animated... And just saying 'we have an API that should do it' without proper testing of a full solution really means 'we're confident it's not yet provably impossible'.

    I'm on board with relying on community for stuff, and building great APIs for them to do so, but renaming/relinking is far too basic of functionality for this kind of outsourcing. I'm not even trying to change hierarchy, just rename them (it lets you attempt to rename in animation window, but that's bugged also).
     
  11. ottolb

    ottolb

    Joined:
    Jul 1, 2009
    Posts:
    42
    Yeah this has been an issue for a long time.
    The workaround I used now is to open the anim clip using a text editor or Mono Develop and manually replace game object name. Remember to use Replace All :).

    I think asset serialization must be Force Text. And make sure you made a copy of anim clip, just in case.
     
    hossenshovon1, JVimes, Tivaly and 4 others like this.
  12. dikar771

    dikar771

    Joined:
    Oct 30, 2015
    Posts:
    19
    Workaround with open anim clip in text editor and "replace all" corrupts the files, so Unity can't use them. Unity-Animation-Hierarchy-Editor works, but it fills every animation frame with value. Only solution that works for me is to copy and paste curves values from one property to another.
     
    LISUZHI2 and Mehrdad995 like this.
  13. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Best non-Unity solution.
    Anybody having hierarchical assets (characters) created by in house or contract artists need to request and require proper naming conventions from inception of a characters concept/design all the way to authoring/exporting to ensure this isn't a problem once in development in Unity.

    Important to check hierarchies and ask for changes when the results are generic bone001/null001/bip001 naming conventions on character rigs.
    Its unfortunate theres no way to inspect a character hierarchy structure for proper naming in the asset store package contents display.
     
    Sangar-Zucchi likes this.
  14. cozduin

    cozduin

    Joined:
    May 3, 2015
    Posts:
    19
    I also had this problem, after moving some files inside the Hierarchy.

    I don't think that the fact there is a script is a good solution, nor it's compatible with Unity principle of ease of use. The advantage of moving and renaming things inside Unity is that Unity automatically rebinds almost anything.

    In theory you can do anything by API, code and external tools. Even have an entire engine by external tools. But then what would be the use of Unity? The theory is the same, I think it's a dissonance from the rest of Unity ease of use principles.
     
    Last edited: Apr 13, 2016
    skullthug likes this.
  15. lukaskrepel

    lukaskrepel

    Joined:
    May 17, 2016
    Posts:
    1
    Has there been any progress on this?

    Not being able to rename or change the hierarchy of objects without completely breaking animations is very limiting to the creative process. I am an animator by profession, who recently dove into Unity. This is basic stuff in any animation package.

    Changing structure and names is often required after creative choices are made. Planning ahead doesn't always cut it.

    At least there should be a quick way to relink 'lost' object to other objects.
     
    Kaldrin likes this.
  16. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    238
    +1 to the sentiments here.

    Perhaps you could detail why this is even hard to do, from a technical perspective.

    Can't you have an internal ID and use the name as a "friendly name" and then have a simple hash table that gets updated when a name is changed?

    Why is making the name of something, a very unstable value, the ID a good thing?
     
    Last edited: May 31, 2016
  17. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    +1 for animation binding by object ID based
    animation shouldn't depending to object string name, this is the reason why unity animation tool are neglected for intermediate(or above) animation stuff
     
    Kaldrin likes this.
  18. AliShug

    AliShug

    Joined:
    Jul 27, 2014
    Posts:
    1
    +1 for ID-bound animation

    Why the hell would you not use the powerful and (basically) foolproof serialization engine Unity is built on?
     
    Mehrdad995, Kaldrin and MrDizzle26 like this.
  19. pixxelbob

    pixxelbob

    Joined:
    Aug 26, 2014
    Posts:
    111
    +1 Animating UI is incredibly time consuming & frustrating because of basic issues like this. We need to be able to restructure without having to recreate everything.
     
  20. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Has anybody filed a bug report or feedback suggestion for this?
    If so please update here with the case number or feedback link.
    I have GOOD points to vote on a worthy update such as this - now that the forum changed back to useful version.
     
    MrDizzle26 and ottolb like this.
  21. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    Because then your animation is usable by one and only one object. Or at the (unlikely) best, copies of a single prefab. This is fine for authoring tools, because when you rename objects, they can relink things together, but in the case of Unity, animations and objects don't always come from the same source, and are often shared by multiple different game objects.

    This solution might work for some teams, but I can guarantee you that it won't work for all, or even most. And we have to think for all teams.

    Besides this, FBX, the leading format, exports name-based curves, so we have to support that.

    What we can do instead is have "Generic Avatar Remapping", where you could setup a translation mapping between one object (your previous object with previous names) and another (your new object with new names). Then when we do the mapping of AnimationCurves to GameObjects (which usually happens only once at runtime), we can map the animation to the new object names, at very little cost.

    This keeps the flexibility of name-based curves, and lets you reuse animations no matter the naming scheme. This is a lot more robust and flexible than ID based animations.
     
    Mehrdad995, Sycoforge, wlwl2 and 6 others like this.
  22. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Seems doable for me
     
  23. pixxelbob

    pixxelbob

    Joined:
    Aug 26, 2014
    Posts:
    111
    I agree.

    We use mecanim for all our Canvas UI animations.
    Using paths is very brittle but I agree is the best way to allow for reusable animations.
    Especially with UI animations the target path can be a complicated structure that needs to change later when functionality is added. We try to layer animations to target as little as possible but major structure changes are sometimes necessary to support new layout and functions.

    Based on my experience providing a simple way to just rename path would be absolutely perfect.
    Allow target paths to be renamed directly in the animation window using the usual F2 (Win) or Enter (Mac).

    We generally just force text serialization and manually find an replace the paths in the .anim files. Which works great for us at the moment but a more user friendly editor approach would be nice and relativity simple to implement.
     
    Last edited: Aug 26, 2016
    dikar771, MrDizzle26 and khan-amil like this.
  24. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    238
    @DavidGeoffroy Thanks for the detailed explanation, makes sense, I don't live in the FBX curved based world at all so this never crossed my mind. Perhaps this is too bold, but is your solution too ideal? As in it would indeed be great, but currently we have nothing, so wouldn't a gap stop be helpful to at least some people?

    Perhaps a UI layer on top of what @pixelbob is doing? Then your more robust solution?

    Just a thot. Cheers!
     
    theANMATOR2b likes this.
  25. yami7

    yami7

    Joined:
    May 8, 2014
    Posts:
    5
    Hey,
    any news on that matter?

    Can I remap automatically now?
    Can I change name of object so it does not crush animation?
     
  26. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    This issue is still there, we haven't propose any solution yet.
     
  27. RElam

    RElam

    Joined:
    Nov 16, 2009
    Posts:
    375
    What I'd like to see is an optional component for the game object with Animator attached that maps the animation data as a channel to one or more game objects, thus removing the dependency on hierarchy or name. This would not only eliminate the renaming issues, but if you wanted to have a channel apply to multiple game objects, you could. For instance, if I wanted a generic animation state that played when something took damage, and caused lights to flicker, I could animate an object called lights, and upon usage, it could be mapped to glowing eyes on a humanoid robot, or a truck's front and back lights, etc.

    So internally, when I start animating something, it assigns an ID along with the name of the curve data stream as it currently does. Then changing the name would still break path based links, but if using the mapping component, the clip could change name and hierarchy without breaking any usage, as could the usage.

    This could also allow for the animation of things outside it's hierarchy, if a script linked the mapping to it. So, for instance, you could have the ability to pick up melee weapons, and if the weapon has a mapping component with channel data for glow or something, then the melee attack could have the glow timing, intensity, and color all in it's clip data where it should be, without the need to write a translator component to pump those animated values to the weapon, since the mapping component does that naturally.

    Unity's animation system seems so close to that 'animate anything' that it's marketing material says... or at least at present even if you can technically animate anything... you almost assuredly shouldn't. Stuff like this, I think, could help fix that.
     
    Walbert-Schmitz likes this.
  28. Luk3ling

    Luk3ling

    Joined:
    Jul 6, 2014
    Posts:
    1
    This may not actually address the issue as directly as many would like, but what about something as simple as being able to add "Notes" or a "Nickname" to a game object in the hierarchy/animation window..? The problem for me is that I've used a lot of free assets made by other indie developers, and while many can and do produce quality content, they also don't always use proper naming conventions for their assets.

    Getting an asset that serves my needs but every part of its armature is named "Box#" or "IK#" is rather disappointing. If I we could apply nicknames that are only useful as an interface with the developers and have no other bearing on a project (I.E Only exists as a marker within the editor UI and is not considered, evaluated or used in any other way) it would alleviate a lot of the troubles of needing to rename objects that are already animated.
     
    1000Nettles likes this.
  29. Bloody-Swamp

    Bloody-Swamp

    Joined:
    Jul 30, 2012
    Posts:
    38
    The solution is quite simple, really.

    When in Animation window, like when you click on Add Property and the properties hierarchy window pops up, you could simply add an Edit Property option when right clicking the "yellow missing" property and a new properties hierarchy window would pop up. Only the properties with the needed type could be shown, and... it's done! Why the fuss, I don't get it.
     
    Last edited: Feb 23, 2017
    dadude123, abertrand and fastgamedev like this.
  30. NightSkiesPony

    NightSkiesPony

    Joined:
    Mar 27, 2017
    Posts:
    2
    Should note that it goes in Assets/Editors. Use the console to figure out errors.
     
  31. Dblincoe

    Dblincoe

    Joined:
    Mar 4, 2017
    Posts:
    10
    Is this still an issue? A little discouraged to be experiencing this problem and see that the original post was created in 2014. I'm running into a problem where I have a complex fbx, but a lot of things like bolts/nuts are named just "bolt" or "nut". I thought that a rename would help me organize and find meshes better but it breaks the animation link and the animation panel is "missing". Is there a way to click in the projects hierarchy panel and have the object highlighted in the animation panel (I know it works the opposite way...click an object in the animation panel and it highlights in the hierarchy panel.) If both selections would/could be synced that would go a long way to helping my main issue of finding objects in these panels.
    Just to add to the sentiment here, this is unfortunate "gotcha" for Unity3d. It is really out of the ordinary for Unity3d environment to not be flexible.
     
    MrDizzle26 and Bloody-Swamp like this.
  32. Peacewise

    Peacewise

    Joined:
    Feb 27, 2014
    Posts:
    52
    Resorting to large text because this has been a problem for years.

    Please fix this:
    Simply add a way to right-click on a property with a broken link for an option to specify a new path. (You already show the path in the hovertip, just let us edit it!)

    It's incredibly simple. The fix on he asset store is just a single file. But it should be built in. Please. And thank you.
     
  33. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    This feature is available in 5.6

    simply click on a property in yellow with missing label to select it, once selected then click again to rename
    rename the path, please note that the root game object name is never included in the path

    missing.png


    rename.png
     
  34. nrajab

    nrajab

    Joined:
    Nov 1, 2016
    Posts:
    1
    @Mecanim-Dev This is great! Would be even better if you could drag and drop the game object to the animation track.
     
  35. Bloody-Swamp

    Bloody-Swamp

    Joined:
    Jul 30, 2012
    Posts:
    38
    Fantastic!
     
  36. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    238
    Circling back to this thread with an alternative approach for refactoring the elements in an animation.

    If you serialize your project assets as 'Forced Text'

    Edit > Project Settings > Editor : Asset Serialization = Forced Text

    Then you can open an animation FooAnim.anim and edit the path to a specific element directly.

    All .anim files are serialized using a YAML format, and are pretty easy to read. If you have a text editor like VS Code, a bulk search and replace along with a little bit of regular expression usage can make refactoring pretty easy.

    Consider wanting to add a 'Neck' element between existing 'Head' and 'Chest' elements. The current path to 'Head' looks something like Pelvis/Chest/Head see the below text version of an .anim file...

    Code (csharp):
    1.  
    2. - curve:
    3.       serializedVersion: 2
    4.       m_Curve:
    5.       - serializedVersion: 2
    6.         time: 0
    7.         value: {x: 0, y: 0, z: 0.111445256, w: 0.9937706}
    8.         inSlope: {x: 0, y: 0, z: 0, w: 0}
    9.         outSlope: {x: 0, y: 0, z: 0, w: 0}
    10.         tangentMode: 0
    11.  
    12.         ... SNIPPED OTHER CURVE INFO ...    
    13.  
    14.       - serializedVersion: 2
    15.         time: 2
    16.         value: {x: 0, y: 0, z: 0.111445256, w: 0.9937706}
    17.         inSlope: {x: 0, y: 0, z: 0, w: 0}
    18.         outSlope: {x: 0, y: 0, z: 0, w: 0}
    19.         tangentMode: 0
    20.       m_PreInfinity: 2
    21.       m_PostInfinity: 2
    22.       m_RotationOrder: 4
    23.     path: Pelvis/Chest/Head
    24.  
    To refactor 'Head' to be under 'Neck' you can simple edit the text after path. This may cause the look of your animation to be off as now 'Head' will be animating relative to 'Neck', and you'll have to do this path replace everywhere, but I find doing it via text find-replace is much faster than manually opening dozens or hundreds of animations and editing them by hand.

    FWIW, you can also do this with the positioning, rotation, etc of an element -- although this is more time consuming as this is all encoded as curve information which so far as I can tell is defined in multiple locations within the .anim file.

    Anyways, hopefully that helps someone.
     
    Last edited: Aug 22, 2017
    ZeFirestarter likes this.
  37. Bloody-Swamp

    Bloody-Swamp

    Joined:
    Jul 30, 2012
    Posts:
    38
    This solution is no longer available in 5.6.3p1 (the one I'm using).
    Or... I have no idea why. The animation is just a sprite renderer changing sprites.
     

    Attached Files:

  38. Bloody-Swamp

    Bloody-Swamp

    Joined:
    Jul 30, 2012
    Posts:
    38
    2017.2.0f3 and still no luck. Althought it worked the first day I installed the new version, the next one it just stopped.
    It's a random bug I guess and needs a lot of testing. But I still believe my suggestion would solve this issue:

     
  39. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    Yes this option is gone for some reason even in version 2017.3
     
  40. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    It not gone, I've just tested it in 2017.3 and it does still work, on windows though

    You need to select the property first, when it change to blue highlighted, simply click once again on it to rename.

    rename1.png

    rename.png
     
  41. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    I've been testing every kind of click possible and it still doesn't work, I'm on windows 10 and the same Unity version as you are.
    I must be doing something wrong here, but I have no idea what, It just doesn't appear for some reason.

    Unity_2018-01-04_22-11-53.png
     
  42. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    @FeastSC2 Do you remember the sequence of operation you did to end up in this state?
    If yes please log a bug and we will investigate.

    Maybe you did reparent the whole animated hiearchy under Bowman Group Game Object?
     
  43. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    I'm not sure what you mean with the 2nd question, my animator is on the "Bowman" gameobject.
    I'm not using Mecanim with skinned meshes, only with 2D sprites and animating script values.

    As far as I understand it there's no particular sequence of operations that led me to not seeing this rename option, with all the stuff I've done in the Animation window I would've noticed the moment I could rename. I just never was able to do it, that's it.
    To make extra sure I created a new project and replicated what you did, no rename still. (there's just one hierarchy asset in that project but it's not the cause of the problem).
    Unity_2018-01-05_15-08-06.png
     
  44. Gokcan

    Gokcan

    Joined:
    Aug 15, 2013
    Posts:
    289
    Hello @Mecanim-Dev@DavidGeoffroy
    I have an urgent question:( please help me. We are working on a animation project. When I change object hierarchy (parenting) animation positions changes. Animation characteristics changes. How can I solve this problem? Please write me soon because this is a dead lined project.
     
    Last edited: Jan 22, 2018
  45. Gokcan

    Gokcan

    Joined:
    Aug 15, 2013
    Posts:
    289
    Hi @Mecanim-Dev,@Joachim_Ante @DavidGeoffroy
    You guys aware of unity's animation window is worst and most useless animation window among any others(unreal,3ds max,blender,etc) right? I am now working on a project that animates an induestrial equipment that contains many parts. And this is completely impossible with unity. After so long time with unity, I am dissapointed. I seriously think to switch unreal. Because I tried same thing with unreal and it has many advantages such as I can change parent child hierarchy in animation window of unreal. And many many advantages. If I were you, I take those advices...
     
    halley likes this.
  46. Gokcan

    Gokcan

    Joined:
    Aug 15, 2013
    Posts:
    289
  47. Cherno

    Cherno

    Joined:
    Apr 7, 2013
    Posts:
    515
    I really need to change an animationclip's property's path (to the bone in the hierarchy) AT RUNTIME, OUTSIDE THE EDITOR yet it doesn't seem to be possible, you can only use SetCurve to create a new curve with associated path, but not edit an existing one. I wish this would be made available via script.
     
  48. LvM2D

    LvM2D

    Joined:
    Aug 23, 2015
    Posts:
    5
    You can open file animation .anim (it is just a text file with format like json) and you could see "path" key for each object. Change it follow new name/path.
     
    _eternal likes this.
  49. Cherno

    Cherno

    Joined:
    Apr 7, 2013
    Posts:
    515
    I assume that the anim file wouldn't be available with a build?
     
  50. DevinW

    DevinW

    Joined:
    Jun 19, 2014
    Posts:
    37
    Just add a context menu option to the property that renames the path or transform+path...
    such a lazy response... to have every user write a script or download a 3rd party package is totally irresponsible - sure it's a solution today, but be accountable for your own engine and your user's feature requests. It's insane the amount of work put into this window and this simple issue has been a problem since I started using Unity 6 years ago. Unity isn't an open-source project - don't depend on 3rd party assets to fix core engine features.

    I feel bad for all the animators who do not know how to code and have to then bring in 3rd party assets to do a basic engine function.
     
    Last edited: Jan 23, 2020