Question by
RavenThunderclaw · Mar 19, 2018 at 08:33 AM ·
3dcollision detectiondestroy objectif statementhow to
Destry object on collision with 'bullet'
So I've been looking into this for a while. Being a beginner I'm trying to make a simple game where a few boxes will be broken when shot with bullets from my Player.
I've made a box and a similar stack that replaces it to create the broken effect.
The thing is I've managed to do this with getKey() with If statement, but practically I need the Instantiate(smaller_pieces) and destroy(box) to be invoked when my bullets collide with the said box.
I don't understand how to use OnCollisionEnter() for an If condiiton.
This is my Update() function.
void Update () {
try{
if () {
//'remains' is the GameObject which replaces the Box gameObject.
Instantiate (remains);
Destroy (gameObject, 0.1f);
}
}
catch(MissingReferenceException) {
}
}
What should I place inside the if to make it work?
Comment