Skip to content

Instantly share code, notes, and snippets.

@tracend
Created March 30, 2011 00:06
Show Gist options
  • Save tracend/893620 to your computer and use it in GitHub Desktop.
Save tracend/893620 to your computer and use it in GitHub Desktop.
Unity3D: Make a particle explosion when bullets hit - Source: http://wiki.dreamsteep.com/Unity_tools
var explody_pf :Transform;
function explody (){
var instancedbullet =Instantiate( explody_pf ,transform.position,Quaternion.identity);
//instancedbullet.rigidbody.AddForce(transform.forward * shootForce);
}
function OnCollisionEnter (collisionInfo : Collision) {
// print (collisionInfo.gameObject.tag) ; //??? HTH DO I TAG?
// if (collisionInfo.gameObject.tag=="sphere"){
//
// print (collisionInfo.gameObject.transform.position) ;
explody();
var rand: int = Random.Range(-200,200);
collisionInfo.gameObject.rigidbody.AddForce(Vector3.up*1500);
collisionInfo.gameObject.rigidbody.AddForce(Vector3.right*rand);
//}
}
function OnCollisionEnter (collisionInfo : Collision) {
if (collisionInfo.gameObject.tag=="sphere"){
var rand: int = Random.Range(-200,200);
collisionInfo.gameObject.rigidbody.AddForce(Vector3.up*500);
collisionInfo.gameObject.rigidbody.AddForce(Vector3.right*rand);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment