Hiding cubes when it touchs to a ball

Hi ;

I have so many cubes on my scene and when it contacts with a ball i want to hide or remove the cube which touched to the ball. Like my ball will eate the cubes . Is there any way to do this?

Thank you

There absolutely is.

Step 1: On your ball, go into its collision events by clicking on the root of the actor in the top left panel (by default). If you can’t find them then just add a new component called, “sphere collision.”

Step 2: Once you find your collision, find the event called, “begin overlap” This fires when something enters its collider, or it enters something else’s. Double click it.

Step 3: Pull out the wire that says, “Other Actor.” This is the one we’ve collided with.
We’re going to cast this to your cube class, and only pull the top pin so that ensures that this was a cube.

Step 4: Pull out that wire from the cast node and type “destroy.” Make sure they’re attached or else the ball will be destroyed.

Step 5: Go back to your Cube and add a box collider. Make this a little bit bigger than the cube its self.

Step 6: Go to details panel in the left, and go under “collision” just as before, and edit the collision preset to “overlap all.” This allows everything to pass through it, but not the cube itself.

Effectively, this outer collider is a trigger box that we will use to trigger the destroy event. The ball will pass through this outer one and when it does, the cube will be destroyed.

Let me know if you have anymore questions.


Also, this is destroying them. Although you can “hide” them, that will be an extremely bad practice to leave all those references all around.

Also also, if the boxes aren’t doing anything, go into the details panel again and tick the box that says “start with tick enabled” off. This is going to prevent the engine from calling the “tick” for each box 60 times a second.

Don’t use what you don’t need! (:

Were you able to get this working?