Game Development Reference
In-Depth Information
Figure 8-10. Blizzard particle system settings
In the Project panel Assets ➤ Scripts folder, find the KillOnCollision script and open it in
MonoDevelop. Add the following function:
function OnParticleCollision(other : GameObject)
{
if (other.gameObject.name == "Third Person Character Ragdoll")
{
other.gameObject.GetComponent(GoRagdoll).GotoRagdoll();
}
}
The OnParticleCollision() is called when the Send Collision Messages box in the particle system
Collision module is checked. The block of code within the function checks to see if it is the player
character that was the other game object in the collision, and if so calls the player character's
GotoRagdoll function.
Save the script and attach it to the Blizzard game object. As with the Bomb, drag and drop the
Blizzard particle system into the Assets ➤ Prefabs folder in the Project panel. Save the scene
(Figure 8-11 ) and save the project. Playtest and dodge the deadly snowflakes!
Figure 8-11. The player character facing the blizzard obstacle
 
Search WWH ::




Custom Search