car engine sound template

Could you make this script based on wheel torque in stead of lineair velocity?

man this works for me when i use your blend file, but when i copy it it my own it doesnt make any noise? :C

I need help using this

Doesn’t work

Why don’t you all look in the console and see what the error is. This thread is from 2010 and so the code is very outdated.

I’ve updated this script to run in Blender 2.78.

import bge

cont = bge.logic.getCurrentController()
own = cont.owner

####setup
gas = cont.sensors[‘gas’]
sound = cont.actuators[‘Sound’]
pitch = sound.pitch
linvelocity = own.getLinearVelocity(True)
velocity1 = linvelocity[1] * 2
velocity0 = linvelocity[0] * 2 / 1.5
if velocity0 < 0:
velocity3 = velocity1 - velocity0
else:
velocity3 = velocity1 + velocity0
velocity = velocity3 / 2 *2
####actions
if velocity < 1:
sound.pitch = 0.1
else:
sound.pitch = velocity / 12
cont.activate(sound)

Hello Kendrick1397 and everyone. Could you or somebody else tell me…
Is there anything more to set up?
I will be happy if You tell me step by step how to set up and connect logics.
I have created those properties, added sound, properties in the logic, and added python script in the logic. Connected properties to the actuator “sound”. In result i hear car’s engine constantly. Change of the speed of the car does not affect sound. I use quite new version of blender ( do not remember, version and don’t have blender in front of me right now).
I belive that it is matter of unpropper logic set up.

ALSO - I am not sure what is “INT”. Is it the shortcut of “integrer” - type of property?

Regards
Jakub