so
keypress W --------and--------------Direction = “N”
keypress W---------and--------------- Direction = “NW”
keypress A---------/
etc
so in the code, if Direction = “N” then it sets a vector to [-5,0,0] - (Dir is the name of the vector)
later this vector is multiplied by a object attached to the camera, that tracks the player in 2d,
Dir = own[‘Cam’].worldOrientation*Dir
this is then mixed into the players LinV
own.worldLinearVelocity.x = ((own.worldLinearVelocity.x31)+Dir.x)(1/32)
import bge
from mathutils import Vector
cont = bge.logic.getCurrentController()
own = cont.owner
if 'Cam' not in own:
own['Cam']=bge.logic.getCurrentScene().objects['Cube.001']
else:
if own['Direction']=="N":
Dir= Vector([-own['Max'],0,0])
if own['Direction']=="NW":
Dir= Vector([-own['Max']*.5,-own['Max']*.5,0])
if own['Direction']=="W":
Dir= Vector([0,-own['Max'],0])
if own['Direction']=="SW":
Dir= Vector([own['Max']*.5,-own['Max']*.5,0])
if own['Direction']=="S":
Dir= Vector([own['Max'],0,0])
if own['Direction']=="SE":
Dir= Vector([own['Max']*.5,own['Max']*.5,0])
if own['Direction']=="E":
Dir= Vector([0,own['Max'],0])
if own['Direction']=="NE":
Dir= Vector([-own['Max']*.5,own['Max']*.5,0])
if own['Direction']=="None":
Dir= Vector([0,0,0])
CamDir = own['Cam'].worldOrientation.copy()
Dir = CamDir*Dir
own.worldLinearVelocity.x=((own.worldLinearVelocit y.x*31)+(Dir.x))*0.03125
own.worldLinearVelocity.y=((own.worldLinearVelocit y.y*31)+(Dir.y))*0.03125
if own.worldLinearVelocity.magnitude>.05:
own.alignAxisToVect(own.worldLinearVelocity,1,.25)
own.alignAxisToVect(Vector([0,0,1]),2,1)
Attachments
MasterControl.blend (470 KB)