import bge import FSM from mathutils import Vector dict = bge.logic.globalDict class Player: def __init__(self, cont): self.cont = cont self.obj = cont.owner self.FSM = FSM.PlayerFSM(self) self.walking = True #print(self.obj.childrenRecursive) #self.arm = self.obj.childrenRecursive['Char4'] self.arm = None def update(self): self.FSM.Execute() def get_ground_ray(self): axis = 2 distance = -2 start = self.obj.worldPosition end = Vector.copy(self.obj.worldPosition + (self.obj.worldOrientation.col[axis] * distance)) ray = self.obj.rayCast(end, start, 0, 'ground', 1, 0, 0) #print(ray) return ray def get_ground_dist(self, groundray): pass def walk_movement(self): moving = False o = self.obj if dict['kb_w'] == 2 or dict['lUD'] < -.05: #walk_blend(self) if o.linearVelocity.x < dict['max_walk_vel']: o.applyForce([-dict['walk_force'], 0, 0], True) if (dict['kb_lsh'] == 2 or dict['aBut'] == 1) and o.linearVelocity.y < dict['max_run_vel']: #self.run_speed = 1.5 o.applyForce([-dict['run_force'], 0, 0], True) if dict['kb_s'] == 2 or dict['lUD'] > .06: o.applyForce([10, 0, 0], True) #print('w') if dict['kb_a'] == 2 or dict['lLR'] < -.03: o.applyRotation([0, 0, dict['walk_turn_amt']], True) #print('w') if dict['kb_d'] == 2 or dict['lLR'] > .03: o.applyRotation([0, 0, -dict['walk_turn_amt']], True) o.linearVelocity.y *= .9 o.linearVelocity.x *= .95 return moving def update(cont): #print('-------------player updating----------------') dict = bge.logic.globalDict #own = cont.owner if 'player_class' not in dict: #dict['playerFSM'] = FSM.PlayerFSM(own) dict['player_class'] = Player(cont) #dict['playerFSM'].Execute() dict['player_class'].update()