Cannon ball through wall with Havok

Hi everyone,

I have been working on getting this to work in real time. I think I made a solid prototype - in terms of punching a hole through a wall. Was surprisingly tough to get right! I wasted hours on getting this to work with proper physics rules:

  • all sorts of permutations of bricks/collider masses,frictions/restitutions,
  • constraints
  • disposing constraints on collision
  • explosions, forces, impulses

Nothing really worked or looked nice.

Anyway, the idea now is to spawn the destructible parts of the wall in STATIC mode. Then shoot a ray at it. At the point of impact have a probe sphere ready of the size of the hole and see which of the dest. parts intersect. Make these DYNAMIC and spawn an explosion. After a small timeout you make the remaining parts DYNAMIC and spawn a black hole a bit behind the wall which (should) ensure/s that the wall properly collpases. Make sure the ground has high friction.

Some notes:

  • Playground controls: Left mouse mark target, right mouse fire
  • If possible, use thin instances.
  • Definitely spawn display meshes by default. Replace on demand.
  • Values are probably not portable. I needed to change delay and force in my local project.

Best wishes


You nailed the destruction thing! I find it very believable, and works smoothly :ok_hand: By chance I managed not to break it when shooting from the side

1 Like

This is really cool :slight_smile: let me ping @Cedric about the setup difficulties.

I know setting up physics is a long and tedious task. There is a taks in our todo list to add physics editing in the inspector. It might help a little in your case.

1 Like

Pretty good :smiley:. I found a bug…

…Must be the wind:

1 Like

Super cool scene! I remember when we were working on the Playroom demo it was tricky to set up all the cup towers because they wanted to collapse all the time :rofl: You did a great job with yours!

1 Like

Did you check PhysicsBody | Babylon.js Documentation
Also, beware of (big) variation of delta time. this can add instability to physics solving.

1 Like

@Cedric Oh, sorry, I did not mean to complain about Havok! I listed the “fail history” for the purpose of having an audit trail; if people were wondering, why would he do it in such a complicated way.

1 Like