Last active
October 11, 2018 00:50
-
-
Save aidiary/39042aa39593b640e334 to your computer and use it in GitHub Desktop.
Detonator Explosion Frameworkの爆発制御
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma strict | |
var maxFallDistance : int = -10; | |
function Update () { | |
if (transform.position.y <= maxFallDistance) { | |
// 自分自身を削除 | |
Destroy(gameObject); | |
} | |
} | |
function OnCollisionEnter(other:Collision) { | |
// 何かにぶつかったら爆発させる | |
// otherにはぶつかったオブジェクトの情報が入る | |
this.SendMessage("Explode"); | |
// 砲弾は見えなくする | |
// Destroyしてしまうと音声が再生できなくなる | |
gameObject.renderer.enabled = false; | |
// 砲弾も破壊されるのでこれ以上衝突しないようにする | |
gameObject.collider.enabled = false; | |
// ブロックにぶつかったときだけ | |
if (other.gameObject.name == "Brick(Clone)") { | |
// ぶつかった対象のブロックは削除 | |
Destroy(other.gameObject); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment