Game Development Reference
In-Depth Information
In the OnCollisionEnter function, above the //destroy the object line, add:
3.
Vector3 explosionPosition = transform.position; // the projectile's position at the hit
Instantiate (explosion,explosionPosition,Quaternion.identity);
With an explosion of that magnitude, you would expect the potato to be obliterated at the same time.
Change the Destroy lines as follows:
4.
//destroy the object this script is on immediately
Destroy(gameObject);
5.
Save the script.
6.
Assign the SmallExplosion2 to the PotatoAmmo prefab's Projectile
component's Explosion parameter.
7.
Click Play, and shoot the potato gun.
This time the zombie bunnies and the potato that hit them disappear to the accompaniment of a nice
little explosion (Figure 8-15 ).
Figure 8-15. The new explosion when the PotatoAmmo hits
Search WWH ::




Custom Search