This is a closer look at some of the extra controls that were implemented inside of the EA NHL 21 toolkit. The image above displays one of the lower third deliverables that contained a bounding box which would expand or contract based on the length of the type. In addition, I also needed to figure out a way to constrain each of the scripted elements to only animate within a certain region. This was necessary in order to keep these elements from animating all over the place, obscuring the type.

The purple guides represent the min, max, boundingmin, and boundingmax for the X and Y Transform properties. After updating type layers, the user selects each guide and fits it to the outside bounds of the bounding box and the type respectively. They could then right click on each guide to get its value to apply to each corresponding effect.

Code:

min = thisComp.layer("Controls").effect("Min X")("Slider");
max = thisComp.layer("Controls").effect("Max X")("Slider");
boundingmin = thisComp.layer("Controls").effect("Bounding Min X")("Slider");
boundingmax = thisComp.layer("Controls").effect("Bounding Max X")("Slider");
posterizeTime(max/1920+1);
seedRandom(index);
if (random(1) >= 0.5) {
random(min, boundingmin);
} else {
random(boundingmax, max);
}

Code Breakdown:

min = thisComp.layer("Controls").effect("Min X")("Slider");
Find the layer named Controls inside this composition, and on that layer, grab the value from the effect called Min X, which is a Slider Control.

max = thisComp.layer("Controls").effect("Max X")("Slider");
Find the layer named Controls inside this composition, and on that layer, grab the value from the effect called Max X, which is a Slider Control.

boundingmin = thisComp.layer("Controls").effect("Bounding Min X")("Slider");
Find the layer named Controls inside this composition, and on that layer, grab the value from the effect called Bounding Min X, which is a Slider Control.

boundingmax = thisComp.layer("Controls").effect("Bounding Max X")("Slider");
Find the layer named Controls inside this composition, and on that layer, grab the value from the effect called Bounding Max X, which is a Slider Control.

posterizeTime(max/1920+1);
Posterize the time by dividing the max (3840) by 1920 and then add "1". We are forcing this layers animation to be posterized by the predefined max value, dividing it by half the comp size, giving us a value of "2" and then adding "1" to it. Since there were multiple layers using this expression, I either added a value from 1-5 or subtracted a value from 1-5 to give each layer an extra step of randomness.

seedRandom(index);
Generate a random seed value based on a layers index. What is great about this line is that if a change the layer order, add more layers, or remove layers, this will always generate a different value which worked great for my purposes.

if (random(1) >= 0.5) {
random(min, boundingmin);

If the value created randomly by random(1) (which will either be a 0 or a 1) is greater than or equal to 0.5, then generate a random value between the min and boundingmin values.

} else {
random(boundingmax, max);
}

If the value generated is less than 0.5 , then generate a random value between the boundingmax and max values.