void Update()
        {
            if ((particles == null) || (ps.maxParticles != particles.Length))
            {
                particles = new ParticleSystem.Particle[ps.maxParticles];
            }

            int numParticles = ps.GetParticles(particles);

            for (int i = 0; i < numParticles; i++)
            {
                Vector3 force;

                float relativeLife = 1.0f - particles[i].remainingLifetime / particles[i].startLifetime;

                if (AffectedByAllVF)
                {
                    force = VectorField.GetCombinedVectors(particles[i].position) * Multiplier;
                }
                else
                {
                    force = VectorField.GetCombinedVectorsRestricted(particles[i].position, VFRestrictedList) * Multiplier;
                }

                float intensity      = force.magnitude;
                float blendIntensity = hlslSmoothstep(-0.0001f, MinimalInfluence, intensity);

                float finalTightness = Tightness * Tightness;
                if (AnimateTightness)
                {
                    finalTightness *=
                        TightnessOverTime.Evaluate(relativeLife);
                }
                if (AnimateMultiplier)
                {
                    force *= MultiplierOverTime.Evaluate(relativeLife);
                }

                particles[i].velocity = Vector3.Lerp(particles[i].velocity + force * Time.smoothDeltaTime * blendIntensity, force, finalTightness * blendIntensity);
            }

            ps.SetParticles(particles, numParticles);
        }
Beispiel #2
0
        void Update()
        {
            Vector3 force;

            if (AffectedByAllVF)
            {
                force = VectorField.GetCombinedVectors(transform.position) * Multiplier;
            }
            else
            {
                force = VectorField.GetCombinedVectorsRestricted(transform.position, VFRestrictedList) * Multiplier;
            }

            float intensity      = force.magnitude;
            float blendIntensity = hlslSmoothstep(0.0f, MinimalInfluence + 0.0001f, intensity);

            float SQTightness = Tightness * Tightness;

            rb.velocity = Vector3.Lerp(rb.velocity, force, SQTightness * blendIntensity);
            rb.AddForce(force * (1.0f - SQTightness) * blendIntensity, ForceMode.Force);
        }