from bge import logic as G
from bge import render as R
from bge import events
speed = 0.2 # walk speed
sensitivity = 1.0 # mouse sensitivity
owner = G.getCurrentController().owner
# center mouse on first frame, create temp variables
if "oldX" not in owner:
G.mouse.position = (0.5,0.5)
owner["oldX"] = 0.0
owner["oldY"] = 0.0
else:
# round() is a hack to work around the floating mouse bug
x= round(0.5 - G.mouse.position[0], 2)
y = round(0.5 - G.mouse.position[1],2)
x *= sensitivity
y *= sensitivity
# Smooth movement
owner['oldX'] = (owner['oldX']*0.9 + x*0.1)
owner['oldY'] = (owner['oldY']*0.9 + y*0.1)
x = owner['oldX']
y = owner['oldY']
# set the values
owner.applyRotation([0, 0, x], False)
owner.applyRotation([y, 0, 0], True)
# Center mouse in game window
G.mouse.position = (0.5,0.5)
# keyboard control
keyboard = G.keyboard.events
if keyboard[events.WKEY]:
owner.applyMovement([0,0,-speed], True)
if keyboard[events.SKEY]:
owner.applyMovement([0,0, speed], True)
if keyboard[events.AKEY]:
owner.applyMovement([-speed,0,0], True)
if keyboard[events.DKEY]:
owner.applyMovement([speed,0,0], True)
if keyboard[events.EKEY]:
owner.applyMovement([0,speed,0], True)
if keyboard[events.CKEY]:
owner.applyMovement([0,-speed,0], True)
from bge import logic
from mathutils import Vector
GRAVITY = 9.8
def main():
scene = logic.getCurrentScene()
cont = logic.getCurrentController()
own = cont.owner
for obj in scene.objects:
if "gravity" in obj:
down_vec = Vector(obj.getVectTo(own)[1])
down_vec.magnitude = GRAVITY
obj.applyForce(down_vec)
player = logic.getCurrentScene().objects["Player"]
up_vec = own.getVectTo(player)[1]
player.alignAxisToVect(up_vec, 2, 1)
A first camera (avian) and the second code is a ball (planet). When I start the game so the bird will not fly correctly. What is the command I write, and where on the planet in order to be successful flight in accordance with the?