How to make speedometers in racing games?

Could anyone please awnser my questions, I also have a few other question:

  1. how do I get text to show up in my game?
  2. when I play my game on my computer the materials come out wrong (wrong colorurs) but when I play on my brother’s computer the materials are showing up how they’re supposed to, so how do I get the same result on both computers?

I found getLinearVelocity() and getVelocity(point) in the API
but i haven’t had a chance to try and use them yet.

I have kicked a ball off a platform and put damping at 0.5 so it slows down as it moves along. I want to know its speed as it goes.

Seems like this is how.

Follow this tutorial to put dynamic text in the game engine.

For a digital speedometer, you can use this tutorial, and have a python script which uses the functions that coudano mentioned (getLinearVelocity() and getVelocity(point)) to change the text property which controls the text (you’ll understand that part if you read the tutorial).

For a dial speedometer, make your needle and just set rotation ipos at your minimum and maximum speed (though if your dial goes over 180 degrees you will need multiple ipos). Set your keyframes at a 1:1 ratio to your speed. Have the keyframes on the needle object controlled by a property (whose value you will have to transfer from the car).

Theres no link when you sway “this tutorial” about the digital speedometer
and im pretty new to Blenderso how do I “map the UV coordinates around the @”?

sorry if I seem a bit noobish…

I’m sorry. By “this tutorial” I mean the tutorial which I posted a link to in the previous paragraph.

To map the UV-coordinates select the plane which you will be using for your text object and press “F”. This will change you to UV - Face Select mode.

Then, change one of your window types to UV/Image Editor. Hit ALT+O in this window and load your font.

Select all of the verticies in the UV/Image Editor together, and scale, rotate, and move them (together) until they fit neatly around the “@” symbol.

If you follow the rest of the text tutorial, you will be able to check if your tranlations in the UV/Image editor worked. I often end up with the text upside-down and have to rotate it 180.

Does that help?

Yes! thank you!

about my last question( first post): is it just me or does everyone get that problem?

:slight_smile: You’re welcome!

I think the only place where I’ve experienced problems with materials not showing up right is if I transfer a .blend file to another computer, but don’t transfer the textures (or haven’t packed the textures). Then an object which is missing a texture (UV) shows up ugly pink. If this is not the case (it doesn’t sound like it is), then its probably a graphics problem with your computer. I’ve never had a proper graphics card, so I have no experience installing drivers and such. I think my next computer will change that, though.

oh… that explains a whole lot… my bootleg computer sucks
P.S. I need some help with the program that makes the ttf fonts into tga, I keep getting an error and the python highlights “import os” what is wrong???

A really simple way to make a speedometer would be to actually use the distance from the objects current position to its previous position.
for example, you could attach this to your text object:

import math
o = GameLogic.getCurrentController().getOwner()
obj = GameLogic.getCurrentScene().getObjectList()

####  Name of object you want to measure the speed of ###
Name = "Cube"
###   how fast is the cube going if it travels 1 unit
###   per frame?
unit = 10

def dist(pos,posi):
   Z = (posi[2])-(pos[2])
   Y = (posi[1])-(pos[1])
   X = (posi[0])-(pos[0])
   return math.sqrt((X)*(X) + (Y)*(Y) + (Z)*(Z))

pos = obj["OB"+Name].getPosition()
if not hasattr(o, "init"):
   o.init = 1
   GameLogic.pos = pos

o.Text = dist(pos, GameLogic.pos)*unit
GameLogic.pos = pos

what am I doing wrong with the script??/

I have no experience here. I always just stick with the basic arial font in the text tutorial that I cited earlier. Maybe it is possible to download the font you are looking for somewhere else in the proper .tga format?

Hey I finally figured the problem out… anyway I need to know now how I can change the colour, does anyone know?