Separate Engines Thrust for Simulation

I’ve got a tricky problem. Or maybe its not tricky at all and I’m just experiencing noob pains?

I drew a picture to avoid a long descriptive post, see attached. Simply stated I want to achieve simulated flight in blender by using simple local z force in the Bullet engine. If the thruster or propeller turn, the craft turns, due to thrust being pointed in a different direction. Simply see the picture.

I ran into problems simulating this when I started parenting stuff. And yet one solid object doesn’t seem to make a provision for multiple thrusting points - at least that I know of.

The question boils down to this: How do I achieve this simulation? I want to have various thrusters attached to central object. The player enjoys a fairly realistic flight simulation.

Ideas?

Attachments


What a great concept :slight_smile: unfortunately, the only way I can think to achieve this is to have each group of thrusters be linked to a keyboard (or joystick or whatever) sensor directly. Have the actuator be motion and link the key press to whatever you want the plane to do. Hope this helps :slight_smile:

What it sounds like you want is to use Python, particularly the applyImpulse function. The impulse point is relative to the calling object’s position, I believe.

Thanks guys! Apply impulse might be the trick. If I can find a natural fluid way to do it then that might work.

Forgot all about impulse :stuck_out_tongue: best of luck :smiley:

I have an idea, however ambitious it might be!
Lets suppose you have x amount of engines, like on this flier… (watch this amazing video )

What I can do is build a script that uses xyz force and xyz torque based on what your simulated thrusters/propellers are doing. So if one of four rotors spins slower, then a corresponding torque is created.

Or in another case if an engine/thruster rotates from up and down to left and right, then thrust is adjusted for the object.

I guess ultimately I need to construct a formula to plug into python that can take any number of thrusters at various points to the center of gravity and calculate them to assign force properly to that single object.

However it would be far more desireable to have separate thrust points, as this would be a truer simulation.

Why not just use applyImpulse as many times as there are engines, and as the impulse point use the engine’s position? For the force, you should probably use the opposite of the facing direction (-localOrientation.col[1], I think), with the magnitude set to the engines’ power levels.

I’m a little confused on applyImpulse. How do you determine how much force is applied at a given point?

The first value is the point, obviously, but does the impulse take a value similar to what I might plug into force?

(see attached image depicting confusion) :smiley:

If this is what I’m hoping it is, I could apply it at various points per frame as you mention.

Attachments


Alrighty - things are going good. Applying this code gives a nice sharp kick in the air straight up.

obj = bge.logic.getCurrentController() 
obj = obj.owner
bge.types.KX_GameObject(obj).applyImpulse([ 0.0, 0.0, 0.0], [0.0, 0.0, 9.0])

Applying this code gives a nice sharp kick in the air straight up and a slight angle with a spin, since the kick was off-center.

bge.types.KX_GameObject(obj).applyImpulse([ 0.1, 0.0, 0.0], [0.0, 0.0, 9.0])

Now my noob-logic says if I make a mirror impulse in the same frame, it would cause a “balance” where the object would once again go straight up…

bge.types.KX_GameObject(obj).applyImpulse([ 0.1, 0.0, 0.0], [0.0, 0.0, 9.0])
bge.types.KX_GameObject(obj).applyImpulse([ -0.1, 0.0, 0.0], [0.0, 0.0, 9.0])

…but blender crashes. So is this due to the fact that two impulses cannot be applied at the same time? Or do I need to apply this method differently?

You shouldn’t access bge.types directly; an object is an instance of KX_GameObject already, so there’s no need to instantiate one (make a new one).



from bge import logic

cont = logic.getCurrentController()
obj = cont.owner

obj.applyImpulse([ 0.1, 0.0, 0.0], [0.0, 0.0, 9.0]) 
obj.applyImpulse([ -0.1, 0.0, 0.0], [0.0, 0.0, 9.0])


Works perfectly! Thanks @SolarLune.

I build an helicopter with following method:

Have one rigidbody “hull”
Apply other rigid body “engines” via rigid body constraints.

The engines apply forces (via motion actuator). The advantage is you can visually setup the point where the force gets applied.

This works pretty cool. But it is awful hard to fly this helicopter.

Attachments

RigiHeli_heavy.blend (167 KB)

That simulation is absolutely awesome! Thanks for sharing – gonna pack it away for reference.

When I was punching my cube around with applyImpulse I noticed when I scaled down the cube it would hit the ground and do this infinite vibration thing…what causes that?

I was also curious - how can I get the bullet physics engine to mirror real-world values? applyImpulse with a value of 6 gave a nice bat to the object, whereas holding the “force” key down with the same value gave a steady rise.

That is one cute little helicopter… :smiley: My wife loves it too.

Nice that you like the helicopter.
originally it was meant for a demo of something completely different. After a while it was more work on the helicopter rather than the things it should show. Then the helicopter was the only thing left ;).

Try to avoid object scaling whenever possible (on interactive objects). Better apply the scale <ctrl+A>.

flat objects (rigid body) tend to vibrate on flat ground. I guess this is due to precision of the force calculation. I do not know a solution for that. I usually play with the physics setting (object and materials) until it nearly fits my needs.