void UpdateModifier(FearMotionModifierComponent modifier, ref Vector3 velocity, Vector3 position, float deltaTime)
        {
            if (!modifier.Target.HasTarget)
                return;

            var difference = position - modifier.Target.Target;
            float distance = difference.magnitude;

            if (distance > modifier.PerceptionDistance)
                return;

            var direction = difference.normalized;
            float strength = modifier.Strength * (1 - distance / modifier.PerceptionDistance).Pow(modifier.Ratio);

            velocity += direction * strength * deltaTime;
        }
Beispiel #2
0
        void UpdateModifier(FearMotionModifierComponent modifier, ref Vector3 velocity, Vector3 position, float deltaTime)
        {
            if (!modifier.Target.HasTarget)
            {
                return;
            }

            var   difference = position - modifier.Target.Target;
            float distance   = difference.magnitude;

            if (distance > modifier.PerceptionDistance)
            {
                return;
            }

            var   direction = difference.normalized;
            float strength  = modifier.Strength * (1 - distance / modifier.PerceptionDistance).Pow(modifier.Ratio);

            velocity += direction * strength * deltaTime;
        }