Пример #1
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        JobHandle lookAtHandle = new LookAtJob
        {
            lookAtEntities  = Query.ToEntityArray(Allocator.TempJob),
            lookAtPositions = Query.ToComponentDataArray <Translation>(Allocator.TempJob)
        }.Schedule(this, inputDeps);

        return(lookAtHandle);
    }
Пример #2
0
    void OnEnable()
    {
        var idleClip = SampleUtility.LoadAnimationClipFromFbx("Chomper/Animations/@ChomperIdle", "Cooldown");

        if (idleClip == null)
        {
            return;
        }

        if (joint == null)
        {
            return;
        }

        var targetPosition = joint.position + gameObject.transform.rotation * Vector3.forward;

        m_Target = SampleUtility.CreateEffector("Effector_" + joint.name, targetPosition, Quaternion.identity);

        m_Graph = PlayableGraph.Create("TwoBoneIK");
        m_Graph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);
        var output = AnimationPlayableOutput.Create(m_Graph, "ouput", GetComponent <Animator>());

        var animator = GetComponent <Animator>();

        animator.fireEvents = false;
        var lookAtJob = new LookAtJob()
        {
            joint    = animator.BindStreamTransform(joint),
            target   = animator.BindSceneTransform(m_Target.transform),
            axis     = GetAxisVector(axis),
            minAngle = Mathf.Min(minAngle, maxAngle),
            maxAngle = Mathf.Max(minAngle, maxAngle)
        };

        m_LookAtPlayable = AnimationScriptPlayable.Create(m_Graph, lookAtJob);
        m_LookAtPlayable.AddInput(AnimationClipPlayable.Create(m_Graph, idleClip), 0, 1.0f);

        output.SetSourcePlayable(m_LookAtPlayable);
        m_Graph.Play();
    }
Пример #3
0
    protected override JobHandle OnUpdate(JobHandle inputDependencies)
    {
        var handle1 = new FollowJob
        {
            followees = GetComponentDataFromEntity <Translation>(true),
            DeltaTime = Time.DeltaTime
        }.Schedule(this, inputDependencies);

        var handle2 = new LookAtJob()
        {
            targets   = GetComponentDataFromEntity <Translation>(true),
            DeltaTime = Time.DeltaTime
        }.Schedule(this, handle1);
        //
        var handle3 = new AlignJob()
        {
            DeltaTime = Time.DeltaTime
        }.Schedule(this, handle2);

        var handle4 = new MoveJob()
        {
            DeltaTime = Time.DeltaTime
        }.Schedule(this, handle3);

        var handle5 = new RotateJob()
        {
            DeltaTime = Time.DeltaTime
        }.Schedule(this, handle4);

        //var handle = JobHandle.CombineDependencies(
        //    new NativeArray<JobHandle>(new JobHandle[]{ handle1, handle2, handle3, handle4, handle5 },
        //    Allocator.TempJob));

        //ecb.AddJobHandleForProducer(handle);

        return(handle5);
    }