Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expression to pick one of six values based on slider

  • Expression to pick one of six values based on slider

    Posted by James Archibald on November 11, 2014 at 11:34 am

    Hey everyone, this feels like it should be a simple one, and it’s definitely something I’ve achieved before but I’ve sort of tangled myself up and can’t quite see where to go.

    I have a slider that is outputting a value between 1 and 6 based on a wiggle:
    w = wiggle(6,4);
    Math.max(1,Math.min(6,w)).toFixed(0)

    I have 6 nulls in 3D space.

    I then have my effect which I want to wiggle between these nulls based on the slider’s “dice roll”. So far I have defined my variables, but I can’t think how to format the expression in order to achieve this.
    This is how far I’ve gotten:
    dice = effect(“Zap Roll”)(“Slider”);
    t1 = thisComp.layer(“Edge Zap Target 1”).transform.position;
    t2 = thisComp.layer(“Edge Zap Target 2”).transform.position;
    t3 = thisComp.layer(“Edge Zap Target 3”).transform.position;
    t4 = thisComp.layer(“Edge Zap Target 4”).transform.position;
    t5 = thisComp.layer(“Pylon 1 – Top”).transform.position;
    t6 = thisComp.layer(“Pylon 1 – Bot”).transform.position;

    if (dice=1) t1

    So if dice=2, the effect value should be t2, etc.

    Any help would be greatly appreciated.

    • Archie •

    James Archibald replied 11 years, 8 months ago 51,579 Members · 1 Reply
  • 1 Reply
  • James Archibald

    November 11, 2014 at 11:48 am

    Derp, sorted it. Knew it was simple, sorry, folks.

    dice = effect(“Zap Target”)(“Slider”);
    t1 = thisComp.layer(“Edge Zap Target 1”).transform.position;
    t2 = thisComp.layer(“Edge Zap Target 2”).transform.position;
    t3 = thisComp.layer(“Edge Zap Target 3”).transform.position;
    t4 = thisComp.layer(“Edge Zap Target 4”).transform.position;
    t5 = thisComp.layer(“Pylon 1 – Top”).transform.position;
    t6 = thisComp.layer(“Pylon 1 – Bot”).transform.position;

    if (dice==1) t1
    else if (dice==2) t2
    else if (dice==3) t3
    else if (dice==4) t4
    else if (dice==5) t5
    else if (dice==6) t6

    • Archie •

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy