def OnClickExcute(self, player): linearVelocity, angularVelocity = p.getBaseVelocity(player.colId) boostVelocity = vmath.length(vmath.vec3(linearVelocity)) if boostVelocity < 500: boostVelocity = 500 newVelocity = [0, boostVelocity, 0] p.resetBaseVelocity(player.colId, newVelocity, angularVelocity) self.Hide()
def CheckDistance(self): pos, orn = p.getBasePositionAndOrientation(self.obj.colId) disVector = [ self.currentTargetPos[0] - pos[0], self.currentTargetPos[1] - pos[1], self.currentTargetPos[2] - pos[2] ] dis = vmath.length(vmath.vec3(disVector)) if dis <= self.reverseDistance: self.ReverseTargetPosition()
def CheckInsideActiveRange(self, player): player_pos, player_orn = p.getBasePositionAndOrientation(player.colId) for bd in self.finalScene.bodies: if not bd or bd in self.finalScene.activatedBodies: continue pos, orn = p.getBasePositionAndOrientation(bd) distanceVec = [ player_pos[0] - pos[0], player_pos[1] - pos[1], player_pos[2] - pos[2] ] distance = vmath.length(vmath.vec3(distanceVec)) if distance < self.activeRange: # Then activate bd p.changeDynamics(bodyUniqueId=bd, linkIndex=-1, mass=5) self.finalScene.activatedBodies.append(bd)
def ResetPlayer(self, player): pos, orn = p.getBasePositionAndOrientation(player.colId) linearVelocity, angularVelocity = p.getBaseVelocity(player.colId) newPos = [0, 0, pos[2]] p.resetBasePositionAndOrientation(player.colId, newPos, orn) #Target target = [0, 30, 2] direction = [ target[0] - newPos[0], target[1] - newPos[1], target[2] - newPos[2] ] multiVelocity = vmath.length(vmath.vec3(linearVelocity)) self.finalVelocity = newVelocity = [ direction[0] * multiVelocity * 0.05, direction[1] * multiVelocity * 0.05, direction[2] * multiVelocity * 0.05 ] p.resetBaseVelocity(player.colId, newVelocity, angularVelocity)
def CheckDeath(self): linearVelocity, angularVelocity = p.getBaseVelocity(self.colId) velocity = vmath.length(vmath.vec3(linearVelocity)) if velocity < self.kEpsilon: self.isDeath = True # p.changeDynamics(self.colId, -1, mass=0)