- Home /
How to detect collision in scene?
hi...I am learning to make brick breaker game. I have bricks in my game. I have created empty object and added boxcollider2D to it. I want to load next level(scene) if all bricks in current scene are destroyed. how do i do this? I tried ontriggerenter2D and exit2D...but not able to make it work..please help...would be very thankful. Note..its 2D game
One way to load next scene when all bricks are destroyed, is to increase a counter every time a brick is destroyed. And when it reaches amount of bricks, you can load the next scene.
thanks for ur reply...but i have 50 scenes...all with different amount of bricks..
Answer by abi-kr01 · Apr 21, 2015 at 06:48 AM
as @Priyanshu sad One way to load next scene when all bricks are destroyed, is to increase a counter every time a brick is destroyed. And when it reaches amount of bricks, you can load the next scene.
now you must have some script with array or list,try referencing it with that like
if(allbriks.length ==counter)
{
Application.loadlevel(levelcounter);
}
or
if(allbriks.count ==counter)
{
Application.loadlevel(levelcounter);
}
if you don't have it try finding gameobject with tag/name brick and add it to brick array
Your answer

Follow this Question
Related Questions
how do I enable collision? 0 Answers
Tilemap Collider 2D preventing objects from moving 2 Answers
How do you trigger a collider to become enabled after the player collider isn't touching it anymore? 4 Answers
2DColliders going through eachother 1 Answer
How do I get onmouseenter to trigger even if another collider is blocking th? 0 Answers