Skip to content

Particles

Steffenvy edited this page Apr 17, 2020 · 15 revisions

SurfaceParticleSet Asset

This is an asset that defines the particles to be used in an interaction with certain SurfaceTypes

SurfaceData data

  • This is the SurfaceData asset used to define the SurfaceTypes

SurfaceTypeParticles[] surfaceTypeParticles

  • This is auto-resized to the data's surfaceTypes. You will have to reorder them yourself if you reorder the data's surfaceTypes
  • These define some particle interaction settings for the given SurfaceType:
    • Particles[] particles
    • A class containing some settings for particles.
      • SurfaceParticles particles
        • The SurfaceParticles prefab to be used
      • ParticleMultipliers selfMultipliers - ParticleMultipliers otherMultipliers
        • The count/size multipliers for "self"/"other" (read the page "Self vs Other" if you don't know the difference)
      • OriginType originType
        • Other: if these particles are created from the other object, the collidee. Self: if these particles are coming from self, the collider. Both: if you want the particles to be applied to both the "self" and "other" perspectives; ie, if this SurfaceParticleSet is designed to be used for an interaction from "self" SurfaceType x, against the "other" SurfaceTypeParticles x, where x==x (metal-metal, wood-wood, plastic-plastic). Or more succinctly: if this SurfaceType is the same as the one this SurfaceParticleSet will be used on.

SurfaceParticleOverrides Asset

This is an asset that overrides the particles used for an interaction with given ParticleSets, against the objects that are relevant to the Blends that reference this (A (blend-using) Marker's gameObject, gameObjects that use a material used in a material blend override, etc.).

Override[] overrides

  • Override is a class that overrides the interaction for a given SurfaceParticleSet:
    • SurfaceParticleSet particleSet
      • The ParticleSet that this override applies to
    • Particles[] particles
      • Same as before, but used for this override

SurfaceParticles Component

SurfaceParticles[] children

  • You can call children SurfaceParticles prefabs, so that you can for example mix in some dusty particles along with fragment particles. A children SurfaceParticles doesn't call it's own children (this is essentially just to prevent the possibility of infinite loops.)

bool inheritVelocities

  • This should always be enabled unless you have performance problems

float inheritAmount

  • This is how much the velocity inheritance diverges from the (weighted) average velocity, that means if it is 0, then all the particles inherit precisely the weighted average velocity, if it is 1 then particles inherit randomly between the object A and B's velocities. "Weighted average velocity" is the velocity if the inertia of both objects are averaged; if a ball hits a static collider then the weighted average velocity is 0, because the mass of the kinematic collider is "infinity".

Vector2 inheritSpreadRange

  • This is similar to inheritAmount, but it gives the ability to shift the inherited velocity toward one of the objects, such as if you set the range to be (0.5, 1), and it doesn't care about the weighted average velocity: if you set the range to be (0.5, 0.5) then the velocity inherited will always be the straight up average between the velocities.

bool setColor

  • Whether or not you want the color to be multiplied into the particles. This shouldn't be the case if the particles represent for example dust clouds or sparks. This actually multiplies the startColor/s of the ParticleSystem (supports the modes "Color" and "Random Between Two Colors")

float shapeRadiusScaler

  • Collisions find an approximated collision surface radius (used in the ParticleSystem's shape module) by finding the average distance of the contact points to the average contact position. This is not a very good model, because e.g. boxes don't have a circular contact area. This field multiplies the radius found; it should perhaps be something like 0.5.

float constantShapeRadius

  • This number is added to the radius. It doesn't matter how many contacts or how large of an area the contacts cover, this number will always be added just the same. Perhaps this can be used to give a sort of exterior shockwave effect.

Vector3 shapeRotationOffset

  • This rotation is an offset to the ParticleSystem's shape module.

ColliderEffects' Speed Fading

float impactSpeedMultiplier - float rollingSpeedMultiplier - float slidingSpeedMultiplier

  • These multiply the speeds used for CollisionEffects' Particles' Speed Fading range. The reason for this control is that: sparks need sliding friction to be created (rollingSpeedMultiplier ~= 0), whereas dust doesn't care as much about whether the speed is from sliding or rolling. Just a couple more controls to get control over undesired behaviour.

Speed

float constantSpeedMultiplier

  • This is a constant multiplier of the ParticleSystem's main module's start speed. This is useful if you want particles to always be created with a minimum speed even if the CollisionEffects' object is moving very slowly

float speedMultiplierBySpeed

  • This is how much the collision speed affects the start speed multiplier (this is the code used mainModule.startSpeedMultiplier = startSpeedMultiplier * (constantSpeedMultiplier + speed * speedMultiplierBySpeed) where startSpeedMultiplier is cached at Awake).

Count

ScaledAnimationCurve rateByForce

  • The class ScaledAnimationCurve is essentially a lightweight helper class to deal with AnimationCurves easier. This is the code used:
public float Evaluate(float t)
{
    return constant + curveMultiplier * curve.Evaluate(t / curveRange);
}
  • rateByForce is how many particles should be emitted per second while force t is applied
  • You need to be careful with the points of the AnimationCurve. The curve would like to be evaluated from the range (0, maxForce) where maxForce is the largest forces you want. The easiest thing is to set curveRange to be maxForce, be it something like 10000, and set the AnimationCurve to be one of the built-in/default curves within the x range of (0, 1) and the y range of (0, 1). Your job is to shape the curve how you want, how convex, how concave, how whatever, but it would be good to remain within the x(0, 1) y(0, 1) range, and let the other more readable fields do the offset (constant) and scaling.

float countByInverseScaleExponent

  • Further down you will see controls to scale the particles by the forces involved. This is used to decrease the number of particles depending on how large the particles are. The number of particles emitted is multiplied by: 1 / Mathf.Pow(scale, countByInverseScaleExponent) where scale is the size multiplier for the particles.

ScaledAnimationCurve scalerByForce

  • This is used to make the particles larger when the forces are larger