2 Replies Latest reply on Sep 15, 2016 11:38 AM by Rick Gerard

    Calling 1 out of 2 expressions randomly

    lexanetl49110289

      Hi, I used an expression that will move a character to the left or right depending as time moves forward. The character moves left if the slider control number is negative or the character will move right if the slider controller is a positive number.

       

      However, I want to call an expression randomly at the beginning of the scene so that the character will move either left or right randomly depending on which out of the two expression it chose at random. Maybe this can be done with seedRandom() because it'll only choose one random number without switching it every frame?

       

      Here is my current expression:

       

      right = (value)+value*(time/thisComp.layer("Adjustment Layer 2").effect("Slider Control")("Slider"));

      left = (value)+value*(time/thisComp.layer("Adjustment Layer 2").effect("Slider Control 2")("Slider"));

       

      [left[0],value[1]];

       

       

      Basically, I want the the expression to pull out the variable "left" or "right" randomly.

      Is this possible?

        • 1. Re: Calling 1 out of 2 expressions randomly
          Mylenium Most Valuable Participant

          seedRandom() just pins the internal values used in random functions. You still need an actual random() function to generate usable values. The rest isn't really clear. Within a comp the random values are consistent. You can't expect it to be differen every time you open the comp or whatever. Somehow your post doesn't really make sense and you will have to explain better what you actually want to achieve.

           

          Mylenium

          • 2. Re: Calling 1 out of 2 expressions randomly
            Rick Gerard Adobe Community Professional & MVP

            I would probably approach this by creating a sine wave with random frequency and maybe amplitude and then apply those values to a easeOut(sample, sample min, sample max, -max x,  + max x)

             

            sample would be the value of the sine wave, then the minimum and maximum values the sine wave hits, then assign the maximum and minimum x values you want with the slider

             

            Random is too jerky because the number on one frame can be 50 and the next frame can be 500.

             

            You might also what to think about using wiggle and a random generator. Just calling access to a slider value based on random numbers isn't going to work very well.