Battlestar Galactica Viper Thruster RIG

Hi All,

I know this has probably been asked before but I could not locate a thread using the forum search. Basically I want to Play a different action when the key is pressed and when the key is let go. \

In my scene I have a cylinder with it’s origin point located at the bottom. I want the z-scale of the cylinder to be 0.0 when no keys are pressed. When I press the key I want the cylinder to grow, over time, to a scale of 1.0 long the z-axis. Then while I am still holding down the key, it remains at z-axis 1.0. When I let go of the key I want the scale to drop down from 1.0 to 0.0 over time.

Can this be done just with SCA or do I need a script for this kind of setup?


If you choose to do this with a script you can use this:

import bge

keyW =[]
#0 = keyUp, 1 = keyPressed, 2 = keyDown, 3 = keyReleased

if keyW == 2:
   #key down
elif keyW == 0:
   #key up

This is incredibly useful i think :evilgrin:

logic solution
If I have a animation triggered with tap by the false iteration accept on spawn, that is the same,
variable X = 1;
So if Key X is pressed-True Level------------do action 1 and set variable X as 0
if X=0 while key X is pressed-False Level-tap----------Do action 2

this will do an action once when you let go, but not on intiation

You can use the flipper playback type. Just connect a keyboard sensor to an action actuator and set the playback type to “flipper”

It will play the animation until you let go, then it will play the animation in reverse. Also if you release the key when the animation is only half played then it will start from that frame and play in reverse.


Here is an example


LogicDemo.blend (460 KB)

Thanks for all the suggestions.

I have made a discovery, however. When I trigger an action, it does not get recorded with game physics. So triggering an action seems to be out of play at this point.

My goal is to use the BGE for setting up a complex animation, but rendering it in Cycles or BI.

So I actually need a way to set the scale of an object when I press a key. I was looking through the actuators, but I did not find one. Is there an SCA setup that will let me scale the z-axis only upon keypress? Simple Motion only has LOC and ROT, where is Scale?

Ok, if I modify Krystof’s script I get what I want in the BGE.

import bge

bge_scene = bge.logic.getCurrentScene()
con = bge.logic.getCurrentController()
own = con.owner
KEY =[]

#0 = keyUp, 1 = keyPressed, 2 = keyDown, 3 = keyReleased


if KEY == 0:
    # Key up.
    own.localScale[2] = 0
elif KEY == 1:
    # Key pressed.
    own.localScale[2] = 1
elif KEY == 2:
    # Key down.
    own.localScale[2] = 1
elif KEY == 3:
    # Key released.
    own.localScale[2] = 0

But the Game Engine does not record keyframes for the scaling that occurs within the script.

Is this just a BGE bug? When I map a key to the Motion actuator I get key frames recorded. Is that the only actuator that generates keyframes?

As far as I know, “Record Animation” only records the position and rotation of an object.

@HG1: Thanks, I kind of came to that conclusion as well. So I wondered…how can I use position to influence scale without resorting to drivers (which I have never worked with in BGE)?

For my project I am trying to use the BGE as a control system for a Battlestar Galactica Viper. That way I can just fly the Viper around and then render the high quality Viper using Blender Internal or Cycles. So I wanted to link keypresses to thruster output. The thrusters are simply scaled cylinders that need to appear and fade away when keys are pressed and released. A continuous keypress means the thruster must stay on. Upon release the cylinder should fade out.

What I ended up doing was to use BGE scripts to move black sphere based brushes to the surface of a blue canvas, thus leveraging the Dynamic Paint system. But you say….Atom, Dynamic Paint does not work in the BGE. Remember, I am going to use a non-BGE system for rendering. The BGE records the simulation and position of the brush. After your simulation is completed, switch to Blender Render mode and bake the Dynamic Paint cache. The canvas emits a single hair particle with a display type of object, a cylinder image mapped with a flame. The proximity of the sphere to the canvas generates a vertex map that is mapped to particle length. So when the sphere is close, the hair is long. When the sphere is missing, Dynamic Paint start to cool off the vertex map, thus shrinking the cylinder. After all these steps I can control scale from the BGE via keypresses.

In this attached scene I am using the low poly viper model by Henry Tracey as the control cage for the game piece.

To view the results, pull down the BLEND file and bake all caches (takes about 3-4 minutes on my system). Then press play and observe the thruster cylinder generation. To try your own flight press P-KEY over the 3D viewport and used the keys, AWDSQE to control the 6DOF of the viper. When done a bunch of large cylinders will crowd the viewport. Ignore them and immediately bake the cache to see your new flight thrusters.


26_cc-by_viper_mk2_control_RIG.blend (806 KB)