Game Development Reference
In-Depth Information
Step 30. Attach this script to the Snow object.
Because individual particles do not exist to attach script to, this code
attaches to the particle emitter and loops through all its particles. When
it detects a particle's individual energy value has become larger than
the emitter's maximum energy setting, it instantiates a splat. The trick
now is to cause the particle's energy to spike when it collides as this
doesn't happen automatically.
Step 31. Select the Snow object and locate the World Particle Collider
component in the Inspector. Set the Collision Energy Loss to - 100. This
will boost the energy (a.k.a. life) of the particle by 100, which is far greater
than the emitter maximum of 50. When this happens, the attached
particle script test will become true and a splat obj will be instantiated.
Step 32. Before playing, set the Splat value of the Particle Hit script
attached to the Snow to the Splat prefab created before. This is
illustrated in Figure 7.44 .
Step 33. Play. The snowflakes will now create small puffs when they
hit the ground. The final scene is shown in Figure 7.45 .
The very same particle system can be used to create rain. The only
difference would be the size of the particles and the splashes.
FIG 7.44 Setting the snow particle
system up to detect particle collisions
and create a splat.
Search Nedrilad ::




Custom Search