You can do this using some pretty complicated maths. That sounds incredibly fun, but that's probably not something you want to do. Additionally, it might be resource costly.
Instead, I suggest using some pre-made shatter patters. E.g. lets say that you have a 5x5 window you want to shatter. You make a simple window pane out of 1 part. Then, you make another window pane, but out of many more parts, and give it a shattered look. When the window is shot (or whatever), you replace the window pane with the shattered model. Then, you give each shard a direction velocity, and a small random velocity. That way, all the shards will fly in the direction of the bullet, but still fly differently.
If you don't want the same pattern to appear at every window, have multiple shattered windows for each window size, and choose one randomly every time. |