racing game

how do you make a speedometer for a racing game in blender game engine

Add an animation and some initial value props and add an animation from 1 - 100… just use blendenzo’s health tut and modify it to always go up when up arrow is pushed. and always go down at a .5 ratio when it’s not pushed. If you need further instructions just ask and I’ll help.

For a more accurate speedometer, use some simple python to get a better speed value.

If your going for accuracy… it’ll require you to learn python however. My method is logic bricks.

I would like this to be accurate. I dont know much python so how would you make a script that gets the velocity and sets the correct frame for the speedometer.
I am trying to learn python so does anyone know of some decent tutorials?

Umm I’ll do my best. You may have to edit this, as I’m not testing this out. But your blender cmd prompt will display errors.

import GameLogic as GL
cont = GameLogic.getCurrentController()
own = cont.getOwner()


then have it set value of your speedometer to getVelocity I’ll try it and see if I can make a demo blend.

thanks i am not at my house now so i cant test it out until later

Ok I tested it out and there’s an error… I’m fixing it… keep checking I’ll post the edited one in a minute.

you have to get the local velocity in the y axis (or wichever is the one that the car points)

if you are using 2.46 you can do that with this function

myvelocity = own.getLinearVelocity(1)[2]

the one tells the function to get the local velocity and the 2 gets only the y axis of the speed

does anyone know how to set a property value with python?

import GameLogic
cont = GameLogic.getCurrentController()
own = cont.getOwner()
own.nameoftheproperty = value

yeah i figured it out with pieces of the different scripts. i guess it was sort of my first python script

OK here’s the finished blend.

you have to have python 2.4+ installed.

Here’s the code and how it works…

import GameLogic as GL
cont = GL.getCurrentController()
own = cont.getOwner()

velocity = own.getLinearVelocity(1)[1] #Make sure you car is moving via LinV this get's the linear velocity speed and makes a variable named velocity.

own.Velocity = velocity #This sets the property Velocity to the variable velocity.

one more question
how do you set an actuators force

You see where it says LinV… add your force there. set it to Add. I’m uploading another blend with a speedometer in a sec

I was having too much fun! I made a speedometer on it this time!

Don’t just copy my stuff though :wink: take the time to learn my method. Make sure to gimme credit for putting it together.

i mean how do you change the force in python

Ummm first you’d import your actuator

variablename = cont.getActuator(“actuatorname”)

then you’d set the values of it like this… actually just go to and follow that tut…