Fracture Objects That won't slow down the game

I’ve been looking at some ways of optimizing effects in the blender game engine. This has probably been done before but in case it hasn’t I wanted to share a quick method.

I made a simple cube with a brick texture set to static object.

I added a near sensor with a property set to “missile” and an actuator that creates an empty with a life span of about 150. That empty has an actuator that deletes the static cube. The empty is set to no collision.

I made a duplicate of the cube and ran the fracture tool to make five fragments. I placed an empty on each fragment, each set to no collision, and wired each empty to create the fragment in it’s place giving a random life span to each between about 40 and 60. the empties are automatically deleted by the lifespan setting on the original cube.

I parented each empty to the one created by the near sensor on the original cube so they would be created by a single sensor.

Last I added the property “missile” to the projectiles from the gun.

The first cube is on layer one and the empties and fractured pieces are on another layer. With both layers active I made duplicates and stacked them. naturally you have to turn off the second layer to make it work. I originally had a few hundred of them in a stack and I could still blow them all up without slowing issues.

I made a recording of it. It’s one small part of a larger pet project but You can see it a few seconds into the video. The sad part is that my capture software records at a really horrible frame rate. It runs a solid 60fps when I’m playing it.

Let me know if you can get the same thing to work or improve on it. I’d love to see someone else get it working or improve on it.

Attachments


I have to say I can’t see a difference in the video.

If you discover a slow down the first thing is to measure it.
You can simply output a print statement at each frame. Telling the frame number and the system time.
This would show you how much delay you get and when.

To make the situation reproducible (and re-playable) I suggest to use the defined random seed (!=0) for all random calculations. If it is just the life-time of the fragments you do not need that.

For better simulation I suggest to establish an automatic test without manual controls. E.g. the gun fires automatically at game start. The game should end automatic too. The console output is limited!

After that you can play with your settings.
What happens with more fragments?
with less fragments?
Deactivate this/deactivate that.
After each change run the test and document the time differences (obviously with a description of the change).

With this method you should be able to identify your “frame rate killer” ;).

Beside that. If the fracture tool creates such little cones … you can model them manual.
For a good effect I suggest to replace the cube with a few hand made fragments that look like fragments.
Add same dust and no one can tell if the fragments where part of the cube before.

To let a car explode as shown in movies, they fill it with jet fuel and fuse it with a bomb. It looks cool but will never happen in real live :wink: except you are carrying jet fuel and bombs.
Add some special effects to the cube. It looks cool and hides what is going on :D.

Just my opinion

Monster