Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Animation Job Time [SOLVED]

Discussion in 'Animation Previews' started by shamsfk, Apr 22, 2020.

  1. shamsfk

    shamsfk

    Joined:
    Nov 21, 2014
    Posts:
    307
    Hi!
    I have a silly question that bugs me a lot.

    I'm implementing a series of cartoony constraints and it is working wonderfully so far!

    But I hacked my way around disability to get Time.time in the job by adding stream deltas to a hidden property on a jobdata.

    Is there a nicer/proper way to get some global time in the animation job? It is absolutely needed for some sine wave stuff.
     
    Last edited: Apr 22, 2020
  2. Jebtor

    Jebtor

    Unity Technologies

    Joined:
    Apr 18, 2018
    Posts:
    115
    You can retrieve the delta time from the stream using AnimationStream.deltaTime. The damped transform is using this inside DampedTransformJob.cs. I hope this helps :)
     
  3. shamsfk

    shamsfk

    Joined:
    Nov 21, 2014
    Posts:
    307
    Thanks, but that is what I'm doing now.
    What I need is a global time like milliseconds from the start of a program or something like that.

    Currently, I'm adding up all those delta times to a
    public FloatProperty totalTime;

    and it works but feels hacky af. So I'm interested if there is a better or proper solution?
     
  4. Jebtor

    Jebtor

    Unity Technologies

    Joined:
    Apr 18, 2018
    Posts:
    115
    Oh sorry - I misunderstood your original message. There is the AnimationJobCache that you could use to store the global time value. The ChainIKConstraintJob is an example that uses this to store the tolerance and max iterations.
     
    florianhanke and shamsfk like this.
  5. shamsfk

    shamsfk

    Joined:
    Nov 21, 2014
    Posts:
    307
    Works like a charm, thank you!
     
    Jebtor likes this.