Here is the script I have written for my speedometer for my car. It works fine, but I have one problem. I am pretty sure getVelocity returns the global velocity and not the local velocity. At least thats what I think because the script works fine unless I turn the car around. Then the speed is in the negatives.
car = GameLogic.getCurrentController().getSensor("body").getOwner() velocity = car.getVelocity() setspeedprop = GameLogic.getCurrentController().getActuator("setspeedprop") speed = round(velocity*(-2.24), 0) setspeedprop.setValue(str(speed))
Is that what is happening? If it is, then how do you set it to get the local velocity? Sorry, I’ve never really worked with velocity in Python before.
And if you are wondering what the -2.24 is for…
I have the car scaled so that 1 Blender Unit = 1 meter. Since it returns the velocity in blender units per second, you multiply it by 2.24 (meters per second times 2.24 = MPH)