Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How to predict game object position/rotation at a frame in timeline?

Discussion in 'Timeline' started by alkill_981, Nov 4, 2023.

  1. alkill_981


    Nov 4, 2023
    Hi everyone,

    I have a timeline with following tracks: animation track and a custom track A.
    In animation track, I add some animation clip that move and rotation the enemy B.
    In custom track A, I add custom playable asset A (with implement Playable Behaviour A) that do some stuff.
    When the timeline start I need to predict position and rotation of enemy B at frame X. How is the best way to do that?
    I have tried
    at Playable Behaviour A script. Like
    Code (CSharp):
    1. director.time = targetTime;
    2. director.Evaluate();
    3. var targetPosition = enemyB.transform.position;
    But the enemy B position result is sometime right, sometime wrong. I believe that may be the animation update process was executed on sometime at LateUpdate, that make frame lag problem.
    I appreciate any help (y)