I wondered if or how it could be possible to implement explosions. I'm not talking about animations, but about the physical force interacting with other collision-shape objects. My aproach right now would be to spawn several small objects in a circle, spreading away from each other with high velocity. Maybe there is a better way to simulate an explosion?
Related questions: does the material selection of a spatial (ice, wood, steel...) have any effect? Is it possible to break objects apart in smaller pieces? Of course you could do a rule to destroy the object on collision and spawn several smaller pieces, but you would have to adjust this to the size, shape and spawnplaces for every object (if you want to keep it more or less convincing). Or is there a native function for this I haven't found so far?
@Cavaron yes there is a number of ways to simulate an explosion. I simply used the method of applying an impulse to a spatial using the Physics Impulse action. There is a calculation that is done to determine which direction to push the objects. I simply calculate the angle between the explosive object and the box being pushed using an expression helper method "rotationOfAngle( pos1, pos2 )" to determine the angle of force and then use another math calculation to determine a point out in space along that angle.
Here is the equation to calculate the position along the rotationAngle to push objects out:
The (3.14159265 / 180) portion is simply converting an angle from degrees to radians which the sin and cos math helper methods need to calculate the correct values.
I've created a sample project so you can see how it was put together. Each box has a different density which effects how much it will move once the force is applied. The higher the density the heavier the object and the less of an effect. Yes applying materials or different properties to an objects collision shape will effect how it reacts to the blast.
@Cavaron to break objects apart would require custom code. Unless you faked it by just spawning random broken pieces at the point of the object being broken up and destroy the object that is being broken up