- Home /
colliding with 2 objects at a time
i have a moving cube and when it collides with 2 cubes at once I would like to destroy the one that I collided first and not both of them
I am using this script for destroying
function OnCollisionEnter(col : Collision)
{
if(col.gameObject.name == "block(Clone)")
{
if(col.gameObject.GetComponent(materials).curTxt == 1){
ActiveDig = true;
score += 100;
yield WaitForSeconds (2 / drillSpeed);
Destroy(col.gameObject);
}
problem.png
(286.8 kB)
Comment
Best Answer
Answer by Kiloblargh · Apr 10, 2014 at 06:46 PM
if(col.gameObject.name == "block(Clone)" && !ActiveDig)
should do it.
Be sure you are setting activeDig
back to false after 2 seconds, and also you should rename it "`activeDig`" because you don't name variables with a capital letter because just don't.