Can anyone show me how to setup a car engine sound script in Blender 2.70

Can any HELP MEEEE!!! :eyebrowlift2:

Hello,

basically you need setup a actuator in logic bricks with the apropiate sound (sound engine for example, see the image).


Then in a text script (CarSetup.py in this case) you need change the pitch of sound based in the speed (for engine sound in this case).

This is a example, not a working code, i hope you have the idea.
You need link (wire) the controller (of type script) of the object to this actuator (car.actuators[‘engine2’]
in this case)


  from bge import logic as g

.....
.....
....

def sound_engine ( vehicleID, brakes, delay, speed
    sound= car.actuators['engine2']    
    factor = 1300
    
    wr=vehicleID.getWheelRotation(2)
    

    pitch = g.pitch
        
    pitch = round((speed/factor),4)
        
    if pitch >= 0.2:
        sound.pitch = pitch
    else:
        sound.pitch = 0.2    
        
    g.pitch = sound.pitch

Experiment with diferent values of the factor variable.