How to destroy a obstacle or an animal

Is it possible to destroy obstacles in cospaces? If it is possible, can somebody send me an easy instruction about how to code this scenario?

Thank you !!

Hi @Charly_book,

If you want to delete items from a space (for example: after an item is hit, it is removed from the scene), you can use CoBlocks to program this behavior!

Let’s program a space that will delete bricks when our ball comes in touch with them.

(This example builds on top of the physics space made for you in another thread.)

First, let’s create a new CoBlocks script and our Ball - item to CoBlocks. Let’s look for the when item collides... - CoBlock and add it to the white workspace.

Now let’s check if the colliding item is a brick or not. Since we have many items in this space, we simply assume that all items that are not a ramp are a brick. We check if anotherItem (the item which the ball collides against) is not the ramp. If it isn’t, we delete the item.

Let’s check out he code in action!

All bricks that are touched by the ball are deleted!

Hmm, looks like they delete too quickly. We want to see the bricks fly away before they’re removed. To fix that, let’s add a wait - block before the delete block and test the space again:

The final space can be seen here. If you are a PRO user, you can press the remix button to check out the code for yourself :slight_smile:

To learn more about using CoBlocks check out our tutorials in the forum!

1 Like