mardi 10 octobre 2017

Setting Random Rotation Value Over Time (While Loop) - Maya Python

I am trying to set rotate an object each time by a new random number. I am having a problem as the numbers keep increasing instead of staying between the two values set to get a random number between.

def Shake(self,value):
    #Get Rotate Value
    rotVal=cmds.floatField(self.rotFrame, value=True, q=True)
    #Get Start Frame 
    startf=cmds.floatField(self.startField, value=True, q=True)
    #Get End Frame 
    endf=cmds.floatField(self.endField, value=True, q=True)


    # Check if Field is empty 
    if rotVal < 0 or rotVal > 0 :

        #Get a Random Number Between 0 and Rot Val
        randomRotVal = random.uniform(0,rotVal)

        while startf<endf:
            cmds.currentTime(startf)

            cmds.rotate(randomRotVal,randomRotVal,randomRotVal,r=True,os=True)


            cmds.setKeyframe()

            startf = startf + 1




Aucun commentaire:

Enregistrer un commentaire