Problems with using impulse to add thrust to game objects

The attached blend file is an engine pod for a spaceship:
engine pod.blend (1.42 MB)

The spaceship will eventually have four of these pods, but I’m trying to make the physics work right on one of them before I duplicate them. The engine thrust comes by way of applyImpulse, to make this as realistic as possible in terms of how a spaceship operates in zero-g.

I’m having two problems:

  1. When I apply the impulse (press the up arrow), it starts to spin the Engine Pod, not push it forward. (The impulse comes from the python script impulseEngineLag attached to the Glow Impulse spotlight, which is a child of the Engine Pod mesh.) Why is it spinning? I want Engine Pod to be a rigid body, because eventually I want to add small thrusters to provide angular momentum. But I want this impulse to just push it forward, not spin it.

  2. Inside the Engine Pod mesh is a half-sphere named Engine Reflector, which is also a child of Engine Pod. The point of the Engine Reflector is to reflect the Glow Impulse spotlight whose energy is tied to the intensity of the impulse — basically an effect to make the engine look like a space engine. The effect works great except that Glow Reflector always flies away from Engine Pod when Engine Pod starts spinning. Why doesn’t Glow Reflector stay in place relative to Engine Pod? This one is especially interesting to watch in wireframe mode. (I know, per #1 above, I don’t want Engine Pod to be spinning right now, but eventually I do want to add angular momentum, and I definitely don’t want Engine Reflector to be spinning away like it is now.)

Thanks for any help.

Solution to your first problem:
The scales of your meshes are not identical, and neither are their rotations. Select All, hit Ctrl+A and apply scale and rotation to everything.

As for the second problem all I could add is: why not use parent.applyForce(0,owner[‘actualPower’],0),True) instead of applyImpulse?

apply force can’t be localized to a point

Like Nines said, make sure the the scales/rotations are consistent. I also spotted that the Engine Reflector object is set to static. I’ve found that mixing dynamic/rigid bodies with static objects can create physics issues. So set that no collision so as not to interfere with the Engine Pod physics. Which is probably why your glow reflector files away when the engine pod is spinning out of control.

As to why the engine just spins. That’s because you’re using the wrong centre for applyImpuls(). You’re applying the impulse to EnginePod, but using Glow Impulse as the centre. A quick fix in impulseEngineLag.py:


        if owner['colorB'] < 1:
            owner['colorB'] += .005
        owner.color = [owner['colorR'], owner['colorG'], owner['colorB']]
    #   
    # change spotsize attribute from 20(?) to 120 degrees
    vector = owner.worldOrientation.col[2]
    impulse = vector * owner['actualPower'] / 1000

    # changed to use the Engine Pod position, ie the parent
    position = parent.position
    ##


    parent.applyImpulse(position, impulse)
    owner.sendMessage("changingSpeed")

Hope this Helps!

I use apply impulse in my own assemblies,

my systems can be assembled in game :smiley: