# Animation nodes, barchart, I can generate the bars, but how do I animate them?

Newbie with animation nodes.

Through various tutorials, I've managed to come up with the following nodetree (blendfile: https://mega.nz/#!WHhXQKgK!jY9JOj2t-OHm_srS-ysibNsU7nSLnfmmBcRuPsBM9is )

This tree generates bars in a barchart, from an original object (cube) that is hidden from both render and view. The height of the bars, and the number of bars, is determined by the contents of a blender text-blok with CSV-like data in it. First I split the textblock into lines (only the first line is used at this stage), and then I split that line by a custom defined seperator (in this case it's just a single spacechar)

I was hoping that I somehow could feed the resulting barobjects to another transformation-output and mix the values. The goal is to make it possible to eg. make the bars appear from left to right, perhaps make them "grow" from zero to their final size, perhaps even apply some snazzy f-curve or similar to put some bouncy/springy/whatever effect on the animations etc ...

I've been searchin' and searchin' - still I have absolutely zero clue on how to continue. If I simply add another transformation output, that output will totally overwrite the transformations set in the first transformation-output - no mixing whatsoever.

Can someone perhaps point me in the right direction?

• – Acebone Apr 1 '20 at 12:21
• Great, looking forward to it! – Acebone Apr 1 '20 at 13:31
• In future, I suggest blend-exchange.giantcowfilms.com for sharing blend-files. – Leander Apr 1 '20 at 13:43

Click on the image to enlarge it.

I prefer to do the math on single values with Math nodes, which is why I have moved the Combine Vector to the back.

To get the time offset in the scaling animation, we start with the index of each cube from the Index output. With the Time Info node, we can get the current frame.

If we subtract the index from the frame we can get an offset for each element. If we multiply the index with an arbitrary factor before that, we'll get a bigger or smaller offset

frame   -   index  *  3   =  result
9     -     0    *  3   =  9
9     -     1    *  3   =  6
9     -     2    *  3   =  3
9     -     3    *  3   =  0
9     -     4    *  3   =  -3


We can clamp the result from 0 to 1 and use it as the input to a MapRange node. The MapRange node also has the advantage of having an interpolation mode input. As you can see with the frame offset by the index, the first bars from left to right switch from 0 to 1 earlier.

This switch from 0 to 1 plays back the animation in the MapRange nodes output, so make sure to set the OuputMin to 0 and the OutputMax to our desired height of the value which you obtain from the ParseNumber node. (This part remains as in your original node graph.)

Because this switch from 0 to 1 only takes a single frame the animation of the bars change from one frame to another (and thus is not visible as an animation). Simply add another multiply node after our previous result, scaling the time downwards so that the 0-1 happens over multiple frames. I named this multiplier StrechAnimTime.

You may have noticed that this animation takes the same time for all bars making the longer bars move faster than the shorter bars. To make the animation time more proportional, use a multiplied version of the height (Parse Number result) for the InputMax of the MapRange node.

Much more dramatic.