Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

How to keep position and enable Aniamtor when timeline finished?

Discussion in 'Timeline' started by cg_han-squirrel, Jan 15, 2019.

  1. cg_han-squirrel

    cg_han-squirrel

    Joined:
    Nov 27, 2013
    Posts:
    44
    HI, I have some NPCs in my scene, when player enter a specific zone it's triggered to play a timeline that the NPCs move into camera and start a battle.

    The NPCs have their own animator, include states such as IDLE/RUN/ATTACK.
    I want they stay at their position when timeline finished and turn into their own animator logic. When I use the wrap mode "Hold" it's stopped.But if I chose "None" wrap mode, it's go back to their position before timeline played.(I have to force set transform.position via script after timeline finished, it's so ugly..)

    So, is there an elegant way to solve this problem? Thank you very much.
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    When root motions are setup correctly on your animations (and enabled on the animator) this should 'just work'. Which version of Unity is this, and are you using Humanoid or Generic?

    We've also seen a few issues lately when 'optimize game objects' is on. If you are using that disabling that is worth a try
     
  3. cg_han-squirrel

    cg_han-squirrel

    Joined:
    Nov 27, 2013
    Posts:
    44
    Thanks for your replay.
    My unity version is 2018.2.10f1, and I'm using Humanoid.
    My situation like below:


    GIF.gif
    The npc has his own logic, animtor states is IDLE.
    When I enable the timeline(Play On Awake checked), it start to play. But it's blocked at the end of the frame of timeline when timeline finished, when I disable the timeline GameObject, the npc return back to it's start position..

    My question is how to let the npc stay at the end of the timeline's position, and switch state to it's animator?


    The timeline is simply set as below:
    upload_2019-1-16_15-53-58.png
    upload_2019-1-16_15-59-7.png

    upload_2019-1-16_15-54-25.png

    and the root motion of animation set as below:
    upload_2019-1-16_15-55-12.png
     
  4. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Is the apply root motion flag enabled on the animator? That would be the most obvious cause, although the fact that the average velocity on BigSword_Run1 is 0 is also suspicious.

    You also have two animation tracks - Is the second to change the root position?
     
  5. cg_han-squirrel

    cg_han-squirrel

    Joined:
    Nov 27, 2013
    Posts:
    44
    Thank you very much, the key is "root motion flag". When it is enable, the problem solved.
    emmm, it's a little confused, because there would be more than one animation track of a GameObject in a timeline, some is to play character's action, some to play character's position changing. I only want the position changing Track "apply root motion"..
     
  6. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    The second track was the hint that you didn't have root motion setup. In general, it's preferable to have the animation define the motion of the root transform, but it's useful to override it with a second track when that doesn't give the exact results you'd want.

    Instead of using two separate tracks, you can add an override layer to the first track as well. It's pretty much the same, but you only need to define the binding once.
     
    cg_han-squirrel likes this.
  7. cg_han-squirrel

    cg_han-squirrel

    Joined:
    Nov 27, 2013
    Posts:
    44
    Thank you very much!
    Your reply slove all my questions.
     
  8. SamRock

    SamRock

    Joined:
    Sep 5, 2017
    Posts:
    250
    Hey not sure if you need this anymore. But I just found that you can right click on the Clip and Select -"Match Offset to Previous Clip". This ensure that your character starts at the same position as the previous clip positon
     
  9. SkikidDoublePlus

    SkikidDoublePlus

    Joined:
    Aug 11, 2021
    Posts:
    3
    some options shown don't exists as I've seen in the latest version, what do i do?