def create(self): """Spawn a new projectile.""" if self.cooled_down: position = self.entity.position handle = self.engine.entity_manager.create_handle() projectile = self.engine.entity_manager.create_entity(handle, self.projectile_type, position=position) body = self.engine.physics_system.register_entity(projectile, 1, PlayerMotionState) direction = self.entity.motion_state.orientation * (0, 0, -1) body.setLinearVelocity(vector.ogre2bullet_vector(direction * projectile.speed)) self.projectiles.add(projectile) projectile.start_death_timer() self.cooldown_timer.reset()
def move(self, x, y, z): current_speed = self.entity.rigid_body.getLinearVelocity().length() if current_speed <= self.MAX_SPEED: force_direction = vector.ogre2bullet_vector(self.entity.motion_state.orientation * (x, y, z)) self.entity.rigid_body.applyForce(force_direction * self.FORCE_APPLIED_PER_TICK, bullet.btVector3(0, 0, 0))