Search Unity

Update order problems

Discussion in 'Timeline' started by kurzemnieks, Feb 2, 2018.

Thread Status:
Not open for further replies.
  1. kurzemnieks

    kurzemnieks

    Joined:
    Nov 22, 2012
    Posts:
    16
    Hi. There is a problem of frame delay in my custom playable.

    I created new type of track/clip that does dynamic parenting/constraint - you can specify parent and transform offset in clip and then object assigned to the track gets transformed as if parented to the parent object. You can blend between clips to change parenting - super useful when attaching objects to character hands and allow dropping or giving things to other characters etc.

    The problem is when using animated characters - my virtual child object transformation is always delayed by what looks like a frame. It looks like my custom mixer gets calculated before skeletal objects get their new transformation values.
    Solution would probably be to have some sort of update priority system or late update. Any ideas how to solve this issue?
     
  2. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    Edit -> Project Settings -> Script Execution Order.

    If that is not enough look into LateUpdate, or if everything fails call the animator yourself (or better, call your playable Evaluate() or something in LateUpdate())
     
  3. kurzemnieks

    kurzemnieks

    Joined:
    Nov 22, 2012
    Posts:
    16
    Tried Script Execution order - added my Track and Clip classes there (they were the only two showing up in the list), but no luck.

    Only thing that worked was calling playableDirector.Evaluate from LateUpdate. Only thing that worries me is that it means timeline gets calculated twice, which is not very optimal. I could not find a way to access my custom playable behaviour directly to update it.
     
  4. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    When calling it from later update works, that means script execution order must work as well.
    Make sure you add the director to the seo list, not your clip, the director is what executes the timeline.
     
  5. kurzemnieks

    kurzemnieks

    Joined:
    Nov 22, 2012
    Posts:
    16
    I'm not sure if that would work, as my skeletal animations also get updated from the same timeline. In my case it works because everything is updated twice. I guess there is some sort of internal update that happens before late update that calculates final transforms for skeletal animation or something.
    Also I could not find PlayableDirector in the list of Script Execution Order window.
     
  6. angusmf

    angusmf

    Joined:
    Jan 19, 2015
    Posts:
    261
    Please tell me how you did this. Parenting/unparenting simply doesn't work for me (wind up with things out of position at some point, no matter what fix I try,) but I haven't found another way to get the movement of two objects to stay in-sync reliably.
     
Thread Status:
Not open for further replies.