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
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.
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
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.