Airplane flying demo. Python script attempt. Please help. Blend included.

Hello everyone!

Well… Sorry It doens’t work yet…

We are looking for an easy gameplay here, arcade style.
As you can see inside the .blend we are tring to create the “in flight” state.

Critics, commens sugestions are really appreciated. Here is what we have so far:

PYTHON:


import GameLogic
import math
import Blender
from Blender import Mathutils
from Blender.Mathutils import *

# get angle in the Matrix Y axis
def getYAngle(matrix):
    tempMatrix = Matrix(matrix[0], matrix[1], matrix[2])
    return tempMatrix.toEuler().y

# get angle in the Matrix X axis
def getXAngle(matrix):
    tempMatrix = Matrix(matrix[0], matrix[1], matrix[2])
    return tempMatrix.toEuler().x

# get angle in the Matrix Z axis
def getZAngle(matrix):
    tempMatrix = Matrix(matrix[0], matrix[1], matrix[2])
    return tempMatrix.toEuler().z


cont = GameLogic.getCurrentController()
act = cont.getActuator("act")
# gets the object who owns the actuator
obj = cont.getOwner()
upkey = cont.getSensor("up")
downkey = cont.getSensor("down")


## I was trying to play with the force, didn´t work out...
#if upkey.isPositive():
#    act.setForce(act.getForce()[0], act.getForce()[1], act.getForce()[2] + 0.1, 0)
#if downkey.isPositive():
#    act.setForce(act.getForce()[0], act.getForce()[1], act.getForce()[2] - 0.1, 0)

## I was trying to play with the location, didn´t work also...
#if upkey.isPositive():
#    act.setDLoc(act.getDLoc()[0], act.getDLoc()[1], act.getDLoc()[2] + 0.001, 0)
#if downkey.isPositive():
#    act.setDLoc(act.getDLoc()[0], act.getDLoc()[1], act.getDLoc()[2] - 0.0001, 0)

# turns the plane according to Y axis rotation angle
act.setDRot(0, 0, getYAngle(obj.getOrientation())/5000, 0)
# activate actuator
GameLogic.addActiveActuator(act,1)  

Thank you very much for your time!

.BLEND:

Attachments

AirplaneTest1.blend (136 KB)

Very nice! But the nose of the plane is going op when you press up. The tail should go up when you press up, so maybe you can change that…? Very nice steering, though!