4 Replies Latest reply on Apr 9, 2017 3:20 PM by Horshack

    Trim paths, Expression needed (mac)

    rofarra

      Expression needed! Using the trim paths mask, I need the paths to end at random times. I have already looked online and I found this expression,

       

      minDur = 1; maxDur = 5;

      seedRandom(index,true);

      dur = random(minDur,maxDur);

      linear(time,0,dur,0,100)

      and apparently it worked for the reipriant, but it doesn't work for me, please help.

       

      Thanks, 

        • 1. Re: Trim paths, Expression needed (mac)
          Mylenium Most Valuable Participant

          And what exactly doesn't work? You need to explain better and in more detail rather than just saying it wouldn't work.

           

          Mylenium

          • 2. Re: Trim paths, Expression needed (mac)
            Horshack Level 4

            Oops, edit - hadn't woken up yet. It works for me. Perhaps you don't think it was working because the randomly-selected duration is longer than you want. The "minDur" and "maxDur" values specify the minimum and maximum duration (in seconds) that will be randomly selected for the trim paths to complete (ie, reach 100%). Try tweaking those values to taste.

            • 3. Re: Trim paths, Expression needed (mac)
              rofarra Level 1

              thanks for you help, I don't think I need to do it anymore, i have done something that suits my needs better I think, but just to clarify, I put the expression in the 'end' value in the 'trim paths' (which is what Im using to animate it), and the only changes I have been making to this expression has been the numbers, I have been playing around with it with the vague knowledge of how you describe it and it is never been random for some reason, its always been uniform and sometimes a bit glitchy, I will carry on playing around with it because I'm new to AE so it might well be me missing something obvious.

              • 4. Re: Trim paths, Expression needed (mac)
                Horshack Level 4

                The expression you found wont be random across invocations; that's by design. It will always generate the same random end point for the given layer # it is on (random seed is based on layer #, which is the variable 'index'). You can change the random # selected for the invocation by varying the seed, for example statically like this: (100 is arbitrary - use any number to change the seed):

                 

                seedRandom(100,true);

                 

                You can also vary the seed based on a dynamic element, like the layer's position in time. But doing that would require some modifications to the expression.