Search Unity

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

    Joined:
    Jun 10, 2015
    Posts:
    187
    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

    Joined:
    Jun 10, 2015
    Posts:
    187
    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:
    30
    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
    jsebast and dandawes like this.
  11. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    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. Un3mp

    Un3mp

    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.
     
    d1favero likes this.
  14. seant_unity

    seant_unity

    Unity Technologies

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

    jonasj_unity

    Unity Technologies

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

    Meheraj7

    Joined:
    Nov 5, 2015
    Posts:
    81
    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?
     
    d1favero and andyalexnf like this.
  17. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    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:
    81
    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,516
    Is the airbrake part of the timeline, or is it something that happens outside of timeline?
     
  20. Meheraj7

    Meheraj7

    Joined:
    Nov 5, 2015
    Posts:
    81
    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:
    9
    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:
    29
    this BUG should be fixed
     
    d1favero and Meheraj7 like this.
  23. GabrielAguiarProductions

    GabrielAguiarProductions

    Joined:
    Aug 29, 2017
    Posts:
    8
    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:
    81
    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,516
    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.
  26. RuneShiStorm

    RuneShiStorm

    Joined:
    Apr 28, 2017
    Posts:
    264
    Does anyone know how I can move the object without adding an ANimator to it?
    In my case, I want to move the Player up some stairs as an "cutscene" - BUT - the animator controller on my Player is set as a Child. So if I add this animator to the Time line, the player won't actually move to the top of the stairs when the timeline is finished (since all his properties are inside the main object)
    I can solve this by adding an Animator to the main-object, but that messes up the AnimatorController inside the child.
    Difficult to explain but...
    Basically I want to move the Main Player object inside the Timeline, but it seems like I have to have an Animator attached to it.,
     
  27. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    To use the animation track, or any animation clips, you need an animator. If you only want to move the player, and not animate it, you could try using the tween track in the DefaultPlayable package on the asset store.
     
    RuneShiStorm likes this.
  28. RuneShiStorm

    RuneShiStorm

    Joined:
    Apr 28, 2017
    Posts:
    264
    Thanks for the advice but seem to be same problem. It adds an animator to the Player... and that Animator interferes with the animator inside the child :S
     
  29. socialBacons

    socialBacons

    Joined:
    Jun 9, 2019
    Posts:
    2
    I have a problem similiar to this. I made a timeline and an animation but now can't move my character. Only way to make my Character move is by disabling the animator on the Character.
     
  30. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Do you mean you have two animators (at different points on a hierarchy) trying to animate the same object?
     
  31. matthewschaeffer

    matthewschaeffer

    Joined:
    Oct 20, 2016
    Posts:
    1
    Was struggling with this, found a work around for my particular case, maybe this can help someone.

    If you're using an Animator component and animation controller, any state in that controller which references an animation that key frames a change in a transforms position will override any future changes to it's position - even when the animator is not in that state (and thus one would expect to be able to move it freely). Not sure if this is a bug or intended, toggling "Write Defaults" in the state doesn't seem to help. Interestingly if the transform is key framed but doesn't actually change its position (example: uses 2 key frames of the exact same position) the position locking problem will not occur.

    I have a transform that I want to move freely (using a rigidbody), but I also want it's position to be controlled during one of my animations. My workaround to achieve this was to remove it's state from the animation controller, switch inspector to debug to mark the animation as legacy, and play that particular animation from an Animation component instead of from the Animator. This solved my problem - the transform with rigidbody moves freely except for when the animation is playing in which case the position is overridden and controlled by the animation key frames.
     
  32. Crump05

    Crump05

    Joined:
    Mar 29, 2020
    Posts:
    4
    I solved the problem by setting Animation Culling Mode to Update Transforms and unchecking the loop time from the animation window hope this helps
     
    RuneShiStorm likes this.
  33. DeathEvader

    DeathEvader

    Joined:
    Nov 26, 2015
    Posts:
    1
    Can someone help me. I am on 2021.2.4f1 version and I suddenly got this issue. I was working on a cinematic like I have done before without a problem. After making the cinematic when the game should go back to gameplay my character stopped moving. The only different thing i did was I used override track this time. I have to fix it as soon as possible. I have tried reassigning RuntimeAnimatorController using the code above but it doesnt work.. When I enable root motion on my animator the character does move (even though my character doesnt move on root motion) but then other things break like physics collision test. Can someone please tell me a way to fix this without losing my project
     
  34. Ziplock9000

    Ziplock9000

    Joined:
    Jan 26, 2016
    Posts:
    360
    I have a related and simple issue where I can't move a gameobject after a clip that was controlling it completes, but the timeline is still running.

    I have a clip that moves the camera from A to B from 0seconds to 20seconds, after 20 seconds I activate a script on the camera that makes it follow the player. However I can't find a way to make the first clip stop controlling the camera, even though the play head is after the clip itself and the extrapolate is set to none. Blending is not an option either as the are two different things that just happen to control the camera.