How to display units in game?

Hi,

I am looking to have a measurement tool within a game. The idea is to be able to measure the environment while in the game. Is this possible?
I have found a FPS template that has all of the controls setup (wasd and mouse or arrow keys). This template includes a gun and clicking the mouse button shoots the gun and displays a bullet hole on the wall (the environment). I was thinking that it should be possible to shoot at 2 places on the wall have a line appear between the bullet holes and display the distance between the 2 points.
I would appreciate any help with this.

Thanks.

Assuming the two holes are gameobjects, you can measure their distance with getDistanceTo, and then use a text object to display it:

import bge
# get scene and objects:
objs = bge.logic.getCurrentScene().objects
obj1 = objs["HOLE1"]
obj2 = objs["HOLE2"]
text = objs["TextObject"]

# get distance
dist = obj1.getDistanceTo(obj2)

# assign distance to the 'Text' property of the text object
text['Text'] = str(dist) # the text object must have a text property called "Text"

To draw the line search for “laser”. That should show you some results.

This is great. Thank you for the response. I however am new to Blender’s gaming engine and am still having trouble.
How do I add a naming convention to the BulletHole object? Does it always have the same name once it is in the game scene? Do I have to add a script link to the BulletHole object and to the text object as well?
Here is a link to the file: FPS_Template
Thanks again for your help.

I don’t know whether blender assigns names to objects added while the game is in progress; probably it doesn’t.

However what you need are the positions of the two lastly added bullet holes, and an inspection to your code indicates that they can be obtained by storing two consecutive hit_pos “measurements” in bullethole.py script (see line 34).

Unfortunately your file, which I guess was written for a previous blender version, (presumably 2.49) does not run in mine (2.63a) so I cannot try any changes.

Does a FPS game template for blender 2.63 exist? If so, you should consider upgrading your blender version.