im trying to create a dynamic explosion in the BGE, and need to use force fields BUT the only force fields i could find were for particles. i did remember that you can get force in the simple motion actuator but i want something that creates i force blasting away from it (like a granade) that affets other objects. does anyone know how to do this?? do i need big complicated script? please help!
If I understand correctly, you want to make the “shockwave” effect that it’s created when an object explodes, right?
Well, there are many ways to do it. I’ve just made a quick example of how you can do it. Check it out!
FX_poc-Boom!.blend (147 KB)
yeh thats awesome thanks! what exactly did you do? did u just make an invisible wall push everything away or what?
yes… he did
the trick was easy though
…the “clean trick”
which is to have a script that “ray sensor” each single “explodables”
object of the scene (everything if you want, but I would suggest only
dynamic objects that have a “explode” property)
-Ray sensor is to maintain the use of wall to avoid explosions…
then, if the “grenade” look at an object that have the “explode” property,
it get an impulse (applyforce) in the right direction and with a
strength relative to it’s distance from the bomb.
…but idk if this kind of script would slow down the game with
…let’s say 200 possibly explodables object (which is kind of
an arbitrary maximum number of rigid bodies to have in a game
before it start to slow down on to many computer rig)
if someone else have another idea,
I’d be glad to see/read it.
@zebidinofus: It was basically a modified version of the technique used to make bullets. The “bomb” object has a trigger (in this case, a Near sensor). When it’s activated, it creates an instance of a “wall” with a specified life limit. The size of the wall determines the explosion’s range, its shape provides the direction, the force is given by the linV and the life limit sets the duration.
@Ninja Goliath: I’m used to sketch game concepts on the BGE, that’s why I always resort to using the easiest trick to achieve an effect. Of course, I prefer to use python when the time calls for it, like in interfaces, realistic simulation and menus.
However, we agree that there’s no “right” way to do things when it comes to games. It all depends on what you want to achieve and what you are willing to give in return. Ninja Goliath’s method is perfectly valid, and gives you the advantage of controlling which objects will be affected by the explosion. In fact, you don’t need to declare them as a Rigid Body, just change its local position gradually with Loc. Of course, in exchange, this effect doesn’t looks as realistic, but works for some cases. Anyways, with the recent optimizations at the engine, I think it can handle a good number of rigid bodies without problem.
Would that help ??? http://www.tutorialsforblender3d.com/GameDoc/LogicBricks/Actuator_2D.html
“we agree that there’s no “right” way to do things when it comes to games”
your technique was good as well,
yea, I would gain to use simple tricks sometime…
I even did used your technique few months ago hehehe
Nice caught on that force field btw
yeh i was thinking about something like (the properties with relative distance and orientation to the explosion) that but i havnt got a clue how to do python scripting :s
I’m sorry to say I can’t work on that actually,
but Il keep you in touch for when I finally find time to work on that
Then the best for you would be to read some tutorials on python. Try to get used to the language’s syntax and keywords, make some small tests and check out the Blender API. Otherwise, even if we provide you with a working script, you wouldn’t be able to understand it…
sweet, cheers! how hard would it be to write a script for it? and also ive only recently started using this forum and am still trying to get used to it. is it possible to see who has posted on this thread without having to find it every time?
If you want to try and write a python script for calculating your explosions it would work something like this.
An empty or an object to represent the epicenter of the explosion would be spawned. The empty would list through every object in the scene checking distances and adding objects the explosion would effect to a list. Then you could use impluses and possily raycasting to apply force to each object in turn, or you can use object.applyForce() and vectors to send objects in the correct direction. You may want to base the amount of force on the distance to the object. If you want to be really insane, you can even dent your level with the explosion. Just find the level object and loop through every face in the mesh proxy, moving vertices according to their relation to the epicenter, and possibly darkening them at the same time. Then you just use the new recalculate physics mesh function to make physics react to your new hole.
If you could program that script you would have a much more realistic and predictable explosion, but a growing sphere works too.
Another nice thing about the python/impulse based explosion is the extra artistic control you get- for example, car explosions are always cooler if the car flips over, right? Even if the explosion realistically wouldn’t do that, games aren’t about realism- if you move the position of the impulse slightly closer to the explosion, and add a little extra upward force, things will not only fly away from teh explosion but will also be lifted off the ground a bit, and possibly flip interestingly.
If you’ve ever played Pariah, and watched the ragdolls from a grenade, you’ll know what I mean. They fly dramatically into the air, spinning around- instead of just being pressed into the ground as might more realistically happen.