def new_goal(self): self.m_goal[0]=random.randint(0,14) self.m_goal[2]=random.randint(0,14) pos = self.get_rounded_pos() while(pathfinding.point_on_obstacle(self.m_goal) or pathfinding.point_at_pos(self.m_goal,pos)): self.m_goal[0]=random.randint(0,14) self.m_goal[2]=random.randint(0,14) pathfinding.pathfind(pos,self.m_goal,self.m_path) self.m_step = 0
def __init__(self): x=random.randint(0,14) y=0 z=random.randint(0,14) position = [x,y,z] while(pathfinding.point_on_obstacle(position)): x=random.randint(0,14) z=random.randint(0,14) position = [x,y,z] self.m_goal = position self.m_path = [[]] acone = cmds.polyCone() cmds.scale(20,20,20, acone) cmds.rotate( '90deg', 0, 0, acone ) cmds.rename( 'agent' ) self.m_cone = cmds.ls(sl=True) for cone in self.m_cone: # set the initial position cmds.addAttr(cone, longName="initialPositionX", defaultValue=0.0, keyable=True) cmds.setAttr(cone+".initialPositionX", position[0]) cmds.addAttr(cone, longName="initialPositionY", defaultValue=0.0, keyable=True) cmds.setAttr(cone+".initialPositionY", position[1]) cmds.addAttr(cone, longName="initialPositionZ", defaultValue=0.0, keyable=True) cmds.setAttr(cone+".initialPositionZ", position[2]) cmds.setAttr(cone+".translateX", cmds.getAttr(cone+".initialPositionX")) cmds.setAttr(cone+".translateY", cmds.getAttr(cone+".initialPositionY")) cmds.setAttr(cone+".translateZ", cmds.getAttr(cone+".initialPositionZ")) cmds.addAttr(cone, longName="initialHeading", defaultValue=0.0, keyable=True) cmds.setAttr(cone+".initialHeading", cmds.getAttr(cone+".rotateY")) cmds.setAttr(cone+".rotateY", cmds.getAttr(cone+".initialHeading")) # add speed attribute if we need it cmds.addAttr(cone, longName="initialSpeed", defaultValue=3.0, keyable=True) cmds.addAttr(cone, longName="speed", defaultValue=cmds.getAttr(cone+".initialSpeed"), keyable=True) #set the initial speed cmds.setAttr(cone+".speed", cmds.getAttr(cone+".initialSpeed"))