Ejemplo n.º 1
0
    public void ReceiveNewActorMovementData(ActorMovementData newActorMovementData)
    {
        currentMovementIndex = 0;

        actorTargetPoints = newActorMovementData.actorMovePointTransform;
        actorMoveSpeeds   = newActorMovementData.actorMovePointSpeeds;

        SetNewNavigationTarget(actorTargetPoints[0], actorMoveSpeeds[0]);
    }
Ejemplo n.º 2
0
        public static float ApplyDynamics(ref ActorMovementData movement, float time)
        {
            float multiplier = 1f;
            var   move       = movement.Input;

            //All of this is for smooth movement starts and ends, according to Curves in Component
            if (!move.Equals(float3.zero))
            {
                movement.CurveOutStartTime = 0f;

                if (Math.Abs(movement.CurveInStartTime) < 0.001f)
                {
                    movement.CurveInStartTime = time;
                }

                var timePassed = time - movement.CurveInStartTime;

                if (timePassed < movement.Dynamics.timeScaleIn)
                {
                    movement.InRatio = timePassed / movement.Dynamics.timeScaleIn;
                    multiplier       =
                        movement.Dynamics.curveIn.Evaluate(movement.InRatio);
                    if (movement.OutRatio < 1f)
                    {
                        multiplier =
                            Clamp(multiplier +
                                  movement.Dynamics.curveOut.Evaluate(movement.OutRatio), 0f, 1f);
                    }
                }
                else
                {
                    movement.InRatio = movement.OutRatio = 1f;
                    multiplier       = 1f;
                }

                movement.MovementCache = move;
            }
            else
            {
                movement.CurveInStartTime = 0f;

                if (Math.Abs(movement.CurveOutStartTime) < 0.001f)
                {
                    movement.CurveOutStartTime = time;
                }

                var timePassed = time - movement.CurveOutStartTime;

                if (timePassed < movement.Dynamics.timeScaleOut)
                {
                    movement.OutRatio = timePassed / movement.Dynamics.timeScaleOut;
                    multiplier        =
                        movement.Dynamics.curveOut.Evaluate(movement.OutRatio);
                    if (movement.InRatio < 1f)
                    {
                        multiplier =
                            Clamp(multiplier - movement.Dynamics.curveIn.Evaluate(movement.InRatio),
                                  0f, 1f);
                    }
                }
                else
                {
                    movement.InRatio       = movement.OutRatio = 1f;
                    multiplier             = 0f;
                    movement.MovementCache = move;
                }
            }

            return(multiplier);
        }