Quantcast
Channel: Answers by "seedoubleyou"
Viewing all articles
Browse latest Browse all 42

Answer by seedoubleyou

$
0
0
You have to have a way of letting your target object know it's been hit, then replace itself with an explosion animation/sequence/whatever. Many people do this with **Triggers**. When an gameObject's collider is entered by another gameObject, it triggers an action. For example: function OnTriggerEnter(col : Collider) { // Do the exploding stuff here } If you need to be more exacting about what causes the explosion (like a bullet or missile, rather than having your space alien object blow up every time another space alien object crosses into its collider), you can check to make sure that only gameObjects with a specific **Tag** cause the explosion. function OnTriggerEnter(col : Collider) { if(col.gameObject.tag == "Weapon"){ // Do the exploding stuff here } } Also, you might look at: http://unity3d.com/support/documentation/ScriptReference/GameObject-tag.html http://www.unity3dstudent.com/2010/07/beginner-b13-trigger-collision-detection/ http://unity3d.com/support/documentation/ScriptReference/Object.Instantiate.html http://www.unity3dstudent.com/2010/07/beginner-b05-instantiate-to-create-objects/

Viewing all articles
Browse latest Browse all 42

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>