How to make attitude indicator (electronic attitude directional indicator) in BGE

I make f22-Raptor cockpit, but I don’t know how to make attitude indicator.
Can somebody teach me how to make it move / script it?
this is attitude indicator looks like



How to make it move in BGE
Like attitude indicator on the glasses like this video

Please help me about it.

attitude or altitude

which one of this handful of displays do you want to get?

I’d create a text object and call it ‘altitude_indicator.’ and a jet called ‘theJet’ Then do:

theJet = bge.logic.getCurrentScene().objects.get(‘theJet’)
altitude_indicator = bge.logic.getCurrentScene().objects.get(‘altitude_indicator’) #get the text object called ‘altitude_indicator’
altitude_indicator.text = ‘%.0’ % theJet.worldPosition[2] #the text will be theJet’s world z position without the decimal value
altitude_indicator.resolution = 5 #makes the text clear, despite its size
altitude_indicator.color = [0, .25, 1, 1] #will make the text a greenish blue

Place this altitude indicator wherever you want it to be visible in your HUD. Good luck.

Indicator needle value thing…

this

“door” has parts in it that will do exactly what you are looking for,

check the script :smiley:

you can get a great idea of up/down etc by having a ball that is parented into the dash board, and

own.worldOrientation = groundplane.worldOrientation

this will orient the ball to the orientation of your “map ground plane”

Attachments

SceneDoorAlpha.blend (902 KB)Door.blend (506 KB)Jet.blend (1.05 MB)

mmm… I’m not really understand sir
can you give me example blend file sir?

sorry sir, i really not get it
if you see in that videos, I want to ask how to make moving interface at 00:17 until end
I mean, when the jet going up, the number moving and disappear
10---- ----10
| |
5 ---- ----5
| |
0 ---- ----0
| |
-5— ---- -5

hrm…

that sounds like a list display, that the list is edited each frame,

I am not sure how to write it though,

that is with using text, you could have a very large “Strip” image and just change the texture X,Y of a plane to move up and down the strip…

can you help me about it sir?
:frowning:

Ray scanner
To measure the distance to the current ground you can send a ray along -Z (global) then you can read the ray length = high.


MAX_SCANNER_RANGE = 100.0

def setZRayLengthToValue(controller):
  scanner = controller.owner
  scannerTarget = scanner.worldPosition.copy()
  scannerTarget .z -= MAX_SCANNER_RANGE 
  scanResult = scanner.rayCast(scannerTarget, scanner, MAX_SCANNER_RANGE)

  hitPoint = scanResult[1]
  height = MAX_SCANNER_RANGE

  if hitPoint is not None:
     height = scanner.worldPosition.z-hitPoint[2]
     
  setActuatorsValue(controller, str(height))
      
def setActuatorsValue(controller, value):
    for actuator in controller.actuators:
        actuator.value = value
        controller.activate(actuator)

(file: scanner.py; set up module:scanner.setZRayLengthToValue; connect with property actuator)

GPS scanner
If you want the high to a certain reference level (like N.N.) you need to define this level first and read the current coordinates. With that you can determine the distance to the reference level.


def setPositionZToValue(controller):
  scanner = controller.owner
  height = scanner.worldPosition.z
  
  setActuatorsValue(controller, str(height))
      
def setActuatorsValue(controller, value):
    for actuator in controller.actuators:
        actuator.value = value
        controller.activate(actuator)

It assumes 0.0 as reference level.

(file: scanner.py; set up module:scanner.setPositionZToValue; connect with property actuator)

Display
All you need now is how to display the property modified by the property actuator.

You might want to send a message to an according display. See the BGE Guide to Messages incl. Healthbar tutorial for more details.

maby the most simple way to do this is by making an vertex parent to an empty, then always let the indicator track to the empty?..

Here’s an example file of what I said before.

Attachments

altitude Indicator.blend (501 KB)

mmmm…
this is it looks like actually


n this

so you are talking about the artificial horizon?

yes Mr. Monster, that’s it. >,<
sorry my English so bad :confused:

a ball with this code and the top painted blue? (this is outside the poorly made ship) you could move it into a cockpit :smiley:

Always------------python

python

import bge
cont = bge.logic.getCurrentController()
own = cont.owner
scene = bge.logic.getCurrentScene()
ground = scene.objects[‘ground’]
own.worldOrientation = ground.worldOrientation.copy()

this ball will always keep aligned with the ground :smiley:

Attachments

Horizon.blend (467 KB)

I would go with vertex parent too. It does not offer artificial horizon, it also offers compass ;).

And all without any logic.

Except you want it in an overlay scene.