Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

Animation Job precalculated data [SOLVED]

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

  1. shamsfk

    shamsfk

    Joined:
    Nov 21, 2014
    Posts:
    288
    Hi!

    I need to initialize some data on a constraint once and then use it within jobs

    Is this a proper / intended way to do it:

    Code (CSharp):
    1. public class JiggleConstraint : RigConstraint<
    2.         JiggleConstraintJob,
    3.         JiggleConstraintData,
    4.         JiggleConstraintJobBinder<JiggleConstraintData>
    5.     >
    6.     {
    7.         private void Start()
    8.         {
    9.             m_Data.random1 = new Vector3(blah blah);
    10.             m_Data.initialRotation = m_Data.constrained.localRotation.eulerAngles;
    11.         }
    ?
     
    Last edited: Apr 22, 2020
  2. shamsfk

    shamsfk

    Joined:
    Nov 21, 2014
    Posts:
    288
    Ok.... looks like I was almost right)

    Code (CSharp):
    1. public override DampedTransformJob Create(Animator animator, ref T data, Component component)
    2.         {
    3.             var job = new DampedTransformJob();
    4.  
    5.             job.driven = ReadWriteTransformHandle.Bind(animator, data.constrainedObject);
    6.             job.source = ReadOnlyTransformHandle.Bind(animator, data.sourceObject);
    7.  
    8.             var drivenTx = new AffineTransform(data.constrainedObject.position, data.constrainedObject.rotation);
    9.             var sourceTx = new AffineTransform(data.sourceObject.position, data.sourceObject.rotation);
    10.  
     
unityunity