Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Vertical scrolling by fixed amount of pixels

Community Beginner ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

Hi all.

I'm working on a fake livestream chat kind of thing and I need help with the way the messages appear on screen.

I made a really tall image in Photoshop with all the usernames and what they say so i can scroll it vertically in AE. The problem is, I need the scrolling to be ''steppy'' and not smooth. I need it to scroll every time the new ''message'' appears by exactly the same amount of pixels, since the messages are offset by the same amount. Ideally the interval between the messages would be randomized too.

The video is around 10 minutes long, so i can't really see myself doing it manually.

Is there an expression that can do this?

 

Thanks.

TOPICS
Expressions, How to

Views

42

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

Would be trivial for a fixed duration, but randomizing time unfortunately gets you into loop territory because of the reasons explained here:

 

http://www.motionscript.com/articles/speed-control.html

 

Otherwise it would be as simple ass mutliplying an offset value with a quantized index based on time so it moves every n frames:

 

X=value[0];

Y=Math.floor(time/myDuration)*myOffset;

 

[X,Y]

 

Mylenium

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

Bummer about the randomization, but otherwise this is great!

Thank you, I can definitely work with this.

Is there also a way to change it from jumping to the next line, to sliding it there?

I'd like to show my boss some variation.

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

tIndex=Math.floor(time/myDuration);

 

tStart=tIndex*myDuration;

tEnd=(tIndex+1)+myDuration;

 

yStart=tIndex*myOffset;

yEnd=(tIndex+1)*myOffset;

 

X=value[0];

Y=linear(time,tStart,tEnd,yStart,yEnd);

 

[X,Y]

 

Mylenium

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

I have no time to write the expression for you but it could be done with layer markers and a simple accumulator. You just grab the nearest layer marker time then increase the offset by each time using a linear or ease interpolation method. Wait, I have a better idea.

 

If you used text, you could use sourceRectAtTime() to grab the height of each text response and offset each automatically by just using layer in-points so all you would have to do is use the layer index and the in point to animate the move. The text layer would also automatically generate a shape layer background to mimic the Livestream chat. Each text layer would move into the frame and move the others up based only on the layer in point. Then all you would have to do is time the in-point of each layer with the audio. That's probably how I would do it. I already have a bunch of animation presets that do something similar.  It's such a good idea that I think will write one now that would automatically mimic a chat session no matter how many lines of text there are. 

(Edit: I found some time so I'm modifying my reply)

 

An expression to move a layer up based on in point and the size of the text would look like this:

 

src=sourceRectAtTime();
srcTop = src.top;
srcHgt = src.height;
srcPad = 40;
inFrms = 15;
t = time - inPoint;
tMin = 0;
tMax = inFrms * thisComp.frameDuration;
value1 = thisComp.height - srcTop;
value2 = thisComp.height  - srcTop - srcHgt - srcPad;

y = easeIn(t, tMin, tMax, value1, value2);

[value[0], y]

 

 

This expression will move any text layer up from the bottom of the comp so that there is a little padding at the bottom. 

 

The next step is to add the position of each layer above so that the layers are just offset by the height of each text layer plus padding. That should get you started. If I get some more time later today I'll take another look. It shouldn't be that difficult if you rely on the height of the text layer and look at the position of the layer above it.

 

I took a few minutes this evening and modified the first expression to take a look at the layer above. If you put the first expression on the top text layer, then add the following expression to the next layers, you end up with something that looks like text messages scrolling up the screen. Here's the second expression:

 

mstr = thisComp.layer(index - 1);
mstrsrc=mstr.sourceRectAtTime();
mstrTop = mstrSrc.top;
mstrY = mstr.position[1] + mstrTop;

src=sourceRectAtTime();
srcTop = src.top;
srcHgt = src.height;
srcPad = 40;
inFrms = 15;
t = time - inPoint;
tMin = 0;
tMax = inFrms * thisComp.frameDuration;
value1 = thisComp.height - srcTop;
value2 = thisComp.height  - srcTop - srcHgt - srcPad;

if(time <=mstr.inPoint){
	y = easeIn(t, tMin, tMax, value1, value2);
}
else{
	y = mstrY + value2 - thisComp.height;
}
[value[0], y]

 

The comp looks like this:

MessageSimnulation.gif

The padding and the number of frames you want to use to slide in are easily editable. If I had a bit more time I could put another if statement in the second expression so that would not throw an error if there was no text layer above it. This pair of expressions are now two new Animation Presets called MessengerLast and Messenger and Messenger controller. The expressions have been modified, a master slider has been added to set the padding, and background shapes have been created to appear behind the text layers. All I have to do is add a Null, name it Messenger Controller and click on the Messenger Controller preset to add padding, offset, and background color expression controllers to the timeline, then click on Messenger preset to create a shape layer, add a text layer above it, then double click on the MessengerLast preset, add a text layer above that, then select layer 3 and 4 and duplicate them as many times as necessary, and then start editing the text on all of the layers. I then set in and out points and sequence the layers to create my animated conversation.

 

I hope this helps. I think it's the easiest way to do what you want to do without writing a script. It took me about 20 minutes to get it figured out. 

 

Here's the project file from the screenshot for you to take a look at. I hope it helps.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 29, 2021 Jul 29, 2021

Copy link to clipboard

Copied

LATEST

Oh wow, this is incredible! So much more than what i asked for.

Thank you so much for your time Rick!

I'm gonna dissect the project file and apply it to my project.

You saved me a ton of time and trouble!

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines