Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Can't move gameobject after timeline completes

Discussion in 'Timeline' started by Gregwar, Jan 17, 2019.

  1. Gregwar

    Gregwar

    Joined:
    Jan 5, 2019
    Posts:
    9
    I'm not sure if I'm missing something here, but it seems that if you have a custom animator controller on a gameobject, put that gameobject into a timeline and attempt to move its position using the timeline; the object will be unmovable once the timeline completes.

    I've tested this with a brand new project, using a gameobject that only has a sprite renderer an animator and a custom anim controller that only consists of a single sprite. I test if the object can move by attempting to change its transform position in the scene after the timeline completes.

    If I disable and re-enable the "Animator" component, the object will be movable again. Also if I clear the "Animator->Controller" field for "None (Runtime Animator Controller)" this issue does not occur

    Does anyone know why this would be happening? It's a big issue for me since I want to move my playable characters position in a timeline, and continue controlling it after the cinematic.

    This is in a 2d project
     

    Attached Files:

  2. thierry_unity

    thierry_unity

    Unity Technologies

    Joined:
    Jun 10, 2015
    Posts:
    181
    Hi,
    When you say unmovable, you mean that it wont budge at all or that it is reset to it's position?
    A small clip might help to understand the issue.
     
  3. Gregwar

    Gregwar

    Joined:
    Jan 5, 2019
    Posts:
    9
    Sure, I'll post a clip when I'm back at my computer tonight.

    For now when I say unmoveable, I mean it resets its position if you try to move it. For instance, if you click on the game object in the editor, type in a new X value to the transform.position and press enter; it will immediately reset the position to where it was.

    If I enable / disable my animator at this point and try the same test, then the gameobject will properly move to my defined value
     
  4. Gregwar

    Gregwar

    Joined:
    Jan 5, 2019
    Posts:
    9
    Here's a clip of what I'm seeing. The square is being moved from left to right using a timeline. Once the timeline has finished. I cannot change the squares position unless i disable and re-enable the animator
     
  5. thierry_unity

    thierry_unity

    Unity Technologies

    Joined:
    Jun 10, 2015
    Posts:
    181
    Interesting, I wasn't able to repro here unfortunately, if you can open a bug with the attached project and post the bugid here, I will be able to track it down

    sorry about that
     
  6. Gregwar

    Gregwar

    Joined:
    Jan 5, 2019
    Posts:
    9
    I created a bug report for this and uploaded the project twice today. Each time I got a notification saying that "It was successfully uploaded and should receive an email shortly". However after waiting all day, I haven't gotten an email from either attempt.

    Maybe you can find it in the backend?
     

    Attached Files:

  7. jonasj_unity

    jonasj_unity

    Unity Technologies

    Joined:
    Jul 4, 2018
    Posts:
    6
    Hey Greg,
    I can see that there is a project attached to your case, it's okay :)
     
  8. dandawes

    dandawes

    Joined:
    Jan 25, 2013
    Posts:
    4
    Hi, I'm also experiencing this bug but can't find it in the issue tracker. It's like the animation clip that I have on my timeline doesn't clear it's bindings properly and therefore is constantly setting the game objects position.
     
  9. dandawes

    dandawes

    Joined:
    Jan 25, 2013
    Posts:
    4
    I tested in a similar scene to Greg and can recreate this. Not sure if this is the same as Greg's issue but if you:
    -Add cube to scene,
    -create playdirector and animator using the button in timeline,
    -Add animation track, assign cube and add a couple of movement keyframes.
    -Play anim, cube moves and when finished cube can be moved - this all works fine.

    To break it:-
    -Add a separate animator controller and assign it to the cube's controller
    -Play anim and when finished cube cannot be moved

    So I think it's to do with having 2 different animatorcontrollers. We ended up caching the runtimeanimatorcontroller and setting it to null. Then in the animator stopped callback we reassign it to the cached controller and all seems to be back to normal. Hope that helps.
     
  10. Gregwar

    Gregwar

    Joined:
    Jan 5, 2019
    Posts:
    9
    Thanks for the reply dandawes, that's the exact issue i'm seeing. If the animator controller is empty, this issue does not occur. If I have an animator controller assigned, then the gameobject cannot be moved after the timeline sequence completes.

    Caching and re-assigning the controller is what crossed my mind for fixing this too, but it sounds like a work around to a bug in the timeline feature.

    I've been emailing back and forth with unity's bug team in attempt for them to see why this is bad... but so far no luck. The issue id I opened is 1118708, but apparently it can't go public until their QA team acknowledges it as an issue

    Just to re-iterate what the issue is here:
    A timeline that is no longer playing should not override the position of a gameobject that is using an animator controller.
     
    Last edited: Jan 29, 2019
    dandawes likes this.
  11. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,007
    Thanks for the updates on this. I've been following up on this with the animation team, and I've followed up with QA, and the issue filed by @Gregwar should be officially opened up as bug very soon.

    Resetting the animator controller is a good workaround for now. We've been incorrectly assuming this bug was a change in behaviour between 2018.2 and 2018.3 where animator & timeline underwent a lot of animation changes with regard to root transforms. Turns out, the bug exists in 2018.2.

    It appears that once the animator starts writing the root transform (on behalf of timeline), then the state machine continues to always write the root transform even when the state has no root transform animation. Resetting the state machine, as @dandawes pointed out seems to fix it.
     
    dandawes likes this.
  12. Gregwar

    Gregwar

    Joined:
    Jan 5, 2019
    Posts:
    9
    That's great to hear, thanks everyone for the help!
     
  13. Un3mpathic

    Un3mpathic

    Joined:
    Jan 23, 2018
    Posts:
    2
    Hi, I am still experiencing this issue in 2019.1f
    Any updates on this?

    Can confirm that by reactivating the animation on the object "releases" the object again.
     
  14. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,007
    I don't believe there is a bug fix to address this yet.
     
    Un3mpathic likes this.
  15. jonasj_unity

    jonasj_unity

    Unity Technologies

    Joined:
    Jul 4, 2018
    Posts:
    6
  16. Meheraj7

    Meheraj7

    Joined:
    Nov 5, 2015
    Posts:
    46
    So unless you we use root motion , timeline will keep affecting the position of the object? Is there anyway of fixing it for non root motion? my character dynamically switches from gameplay to cutscene and from cutscene to gameplay. but when ever i disable root motion for technical purposes(air brake) my character teleports to the cutscene's origin position. I tried disabling and enabling animator but that only works if i manually do it and not via script. What do you suggest i do?
     
  17. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,007
    In short, yes. If any of the animations played by timeline modify the root transform, then timeline will write the root position and rotation. Whether they are applied using deltas (i.e. root motion) or absolute coordinates is controlled by the animator 'Apply Root Motion' flag, not Timeline.

    So, turning off root motion, doesn't turn off timeline actually outputting root transform information. The animation tracks have an all or nothing approach to root transform animation - if one clip has root motion, or animates root transform, then the entire track outputs root transform information every frame.

    What you described is expected behavior, at least from each systems standpoints, but not necessarily a good or expected workflow.

    For your use case, however, assuming the 'air brake' is in Timeline you could override the root motion instead of disabling it by doing the following:

    1. Create an override track.
    2. Record the desired root motion where the air brakes clip is.
    3. Convert that to a clip track and turn off the clip extrapolation. Maybe add some ease-in/out so it blends to/from the parent track.
    4. Adjust the clip offsets on the parent track on the first clip after the overridden section to account for the change in root motion on the override track. The split tool can be useful here if you are overriding a portion of a larger clip.

    upload_2019-8-22_8-27-41.png

    I hope that helps, at least for your use case.
     
  18. Meheraj7

    Meheraj7

    Joined:
    Nov 5, 2015
    Posts:
    46
    The air brake isnt really a animation and i disable rootmotion even when falling. how do you suggest i bypass this then? Also note i get rid of the player's animator reference in timeline immediately after the cutscene stops
     
  19. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,007
    Is the airbrake part of the timeline, or is it something that happens outside of timeline?
     
  20. Meheraj7

    Meheraj7

    Joined:
    Nov 5, 2015
    Posts:
    46
    Forgot to notify , I fixed it by making runtime animator controller null and in the second line i assigned the animator controller again.
    The airbrake was not part of the time line it was used for dev testing.
     
  21. Mr-Jun

    Mr-Jun

    Joined:
    Jul 1, 2015
    Posts:
    6
    Thanks @Meheraj7 , I stumbled upon this bug as well and reassigning the runtime animator controller worked.
     
    Meheraj7 likes this.
  22. wolilio

    wolilio

    Joined:
    Aug 19, 2019
    Posts:
    4
    this BUG should be fixed
     
    Meheraj7 likes this.
  23. GabrielAguiarProductions

    GabrielAguiarProductions

    Joined:
    Aug 29, 2017
    Posts:
    5
    How did you reassign the runtime animator controller? Did you use a Signal in the timeline that calls a function like this?

    Code (CSharp):
    1.  
    2. public RuntimeAnimatorController animController;
    3.  
    4. public void ResetAnimator()
    5. {
    6.         anim.runtimeAnimatorController = null;
    7.         anim.runtimeAnimatorController = animController;
    8. }
    9.  
    Genuinely curious, I'm having this exact problem but can't seem to be able to fix it.


    EDIT: Found the solution. Apparently if we use a Signal to call a function that will reassign the runtime animator controller it won't work. Instead, I had to reset the animator after the Timeline animation ended, with an Invoke or a iEnumerator.
     
    Last edited: Sep 14, 2019
  24. Meheraj7

    Meheraj7

    Joined:
    Nov 5, 2015
    Posts:
    46
    The way I do it is
    When I play the cutscene I do a unscaled time invoke with the duration of the cutscene. when the invoke function plays I stop the cutscene and reassign the animator in the line after
     
  25. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,007
    Absolutely. Thanks to the users that posted here who made it clear this was still an issue. I made a mistake on the originally filed bug, went back and re-investigated, and reopened it, and there is a fix in flight. Hopefully it will land in a 2019.3 beta soon - it still needs to go through verification.
     
    Meheraj7 likes this.