Search Unity

Question Possible to flip between animating the same object's properties by script or Mecanim?

Discussion in 'Animation' started by Lo-renzo, Aug 15, 2022.

  1. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,511
    I have a gameobject with many children that's animated by Mecanim. My understanding atm is that the animator claims different object properties. I want to animate a child gameobject's transform with Mecanim, then manually animate it via script for other clips, then return it to Mecanim when I play the next animation clip that makes use of that transform.

    However, this doesn't seem supported. I've not been able to switch control of a property back and forth like this. The way I have solved this problem so far is to manually move an empty parent object that's not claimed by Mecanim, yet this workaround clutters the hierarchy.

    Workaround
    -- parent : animated by Mecanim always
    - empty GO : animated by script sometimes, never by Mecanim
    - child : animated by Mecanim always
    - child : animated by Mecanim always​

    Objective
    -- parent : animated by Mecanim always
    - child : sometimes animated by script, sometimes by Mecanim (depending on clip)
    - child : animated by Mecanim always​

    Ideally, I'd like to tell the animator to release a particular property (the transform position/rotation/scale) so that I can flip between manual and Mecanim-driven movement. Is this possible? Any notable implications?
     
    Last edited: Aug 15, 2022