Search Unity

enabling and disabling the Animator component prevents Transform manipulation

Discussion in 'Animation' started by SuhailAlhegry, Nov 16, 2019.

  1. SuhailAlhegry

    SuhailAlhegry

    Joined:
    Dec 22, 2016
    Posts:
    6
    Background:
    I am working on a small game, with robotic enemies that have certain animations (rotating eyes, rotating bodies..etc) done through code with simple Quaternion operations, manipulating bones directly.

    Problem:
    Rotating or moving bones through code works just fine as long as I don't disable and then re-enable the Animator component or the GameObject it's attached to, either via the editor or code; because when I do, the rotation and movement never happen, and I get a jittery in-place movement.

    It seems that the animator is forcing them to reset to their last values before disabling the Animator component; this is confirmed by disabling the Animator component, which allows the aforementioned manipulations to work just fine.

    Notes:
    • I manipulate bones directly by attaching their Transform references to the script component, and manipulating the Transform references directly in LateUpdate. No IK, and no animation layers.
    • I choose the Generic animation type during import.
    What's bugging me is that this behavior occurs only after disabling and re-enabling the Animator or the GameObject, and not when the GameObject is initialized or instantiated.


    Is this the expected behavior or am I messing something?