Esempio n. 1
0
        private void FixedUpdate()
        {
            if (currentFrame != null)
            {
                float sampleTimeX = currentFrame.motion.invertMotionSamplingX ? (1f - currentAnimationFrameProgress) : currentAnimationFrameProgress;
                float sampleTimeY = currentFrame.motion.invertMotionSamplingY ? (1f - currentAnimationFrameProgress) : currentAnimationFrameProgress;

                float rootMotionMultiplier = currentFrame.motion.motionMultiplier * Time.fixedDeltaTime / Engine.pixelsPerUnit;

                Vector3 delta = (Vector3)actor.TransformForwardX(new Vector2(currentFrame.motion.motionX.Evaluate(sampleTimeX), 0f));

                Vector3 targetPosition = transform.position + delta * rootMotionMultiplier;

                float flyDelta = currentFrame.motion.motionY.Evaluate(sampleTimeY) * rootMotionMultiplier;
                if (flyDelta == 0f)
                {
                    actor.flyingHeight = Mathf.MoveTowards(actor.flyingHeight, neutralHeight, Time.fixedDeltaTime * 16f);
                }

                actor.flyingHeight += flyDelta;
                spriteRenderer.transform.localPosition = new Vector3(0f, actor.flyingHeight, 0f);


                actor.MoveToCheckingCollision(targetPosition);



                if (currentFrame.dealsDamage)
                {
                    actor.HandleDamageFrame(currentFrame, targetsHitWithThisAnimation, frameChanged);
                }
                frameChanged = false;
            }
        }