Breakable Walls FX

Create realistic and customizable wall fracture effects in your projects with Breakable Walls FX!

Setup

Setting up Breakable Walls FX is really simple, just follow these steps:

  • Select a wall or flat surface from your game.

  • Add the BreakableWall.cs as a new component.

  • Configure the optional parameters of the script.

Thats it! Now the wall is fragmented and is ready to be destroyed, this could be done either by explosions like its done in the demo scene or in more programatic ways.

How it works

The BreakableWall.cs is the main script of the project. It

This script works in 3 steps:

  • It first creates a voronoi diagram of the same bounds as the wall or plane its on. This is done using the open source library csDelaunay that is included in the Plugins/Voronoi/ folder.

  • The script then iterates through all the voronoi regions of the diagram and for each one of them created a new mesh with the bounds of the region and the depth of the wall. Effectively subdiving the wall into “shards” or “pieces”. Each of these “shards” contains the correct UV coordinates and size making the texture look seamless and making the group of shard look identical to the original wall.

  • After this procedure the original wall is disabled and its replaced by the newly generated, breakable wall.

Misc

The script is pretty extensible and since the voronoi calculations are not done using Unity objects so the parallelization of these calculations can be supported easily.

BreakableWall.cs Script Reference

Property Type Description Default Value
Detail int Detail for the triangulation. This is more or less equal to the amount of triangles on the given surface. 40
OnlySurface Bool Optimization option that only creates front facing part of the mesh for the shard. Useful for far away objects where detail is not needed. false
ShardLayer LayerMask Layer to set shards on when instatiating them. Useful for making raycasts against them. 0


About us

We are a small company focused on building tools for game developers. Send us an email to careers@leastsquares.io if interested in working with us. For any other inquiries, feel free to contact us at hello@leastsquares.io or contact us on the discord





Sign up to our newsletter.

Want to receive news about discounts, new products and updates?