Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Sway 3D object on Z-axis using slider?

Participant ,
Mar 05, 2013 Mar 05, 2013

Hi there,

I have multiple objects (side by side) which I would like to sway on the z-axis as if the wind is blowing them.  I already have their anchor points at the top of each object.  I have a few issues:

  1. I have multiple objest which I would like to have random movement on.  I don't want ALL objest to sway to the left, then ALL sway to the right.  Rather I would like them to be somewhat random/organic.
  2. I need to be able to control all of them with a slider...  I would like to be able to turn the sway up and down and ultimately have them all come to rest at a still position (with 0 z-rotation).
  3. A slider would be ideal as I would like them to gradually stop swaying, not just "on" and "off"
  4. There are about 15 objects to sway.  If there is no way to randomize them I would be happy even to make multiple slider controls so that object 1, 4, 6, etc. would be controlled (and have identical movement) by 1 slider, then objects 2,5,7 etc. would be controlled by another, and so on.  I suppose this would simulate randomeness but would not be ideal.  I would like the slider conrol to be dead simple.

Any thoughts?

Thank you very much!

-Stephen

TOPICS
Expressions
1.9K
Translate
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 Expert ,
Mar 05, 2013 Mar 05, 2013

Set different random seeds for each layer. You could use the layer index for that. Set up a value at time expression and use the layer index to add variations of timing to each layer. Use the slider to control the amount of sway either as a percentage or as a max value for a min max expression. Are you experienced enough with expressions to try and write it or was the preceding just so much nonsense to you?

Translate
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
Participant ,
Mar 06, 2013 Mar 06, 2013

Thank you Rick,

Unfortunately I'm not too experienced with writing expressions (especially ones I've never used before) but I am able to read expressions somewhat.  And as long as I know the term to search for "random seeds?" I should be able to google some help.  Do you have ideas off the top of your head for the sway expression? 

Here's is a hodgepodge expression which I don't recall if I pieced it together or found it complete (this was last month that I worked on this project).  I thought i could customize it to ramp the sway on and off or even use a decay (is that the right term) expression to have it slow down over time (say, after 1 second it slows to a stop):

swingMaxDistance = thisComp.layer("controls").effect("sway1")("Slider");

swingSpeed = thisComp.layer("controls").effect("sway1")("Slider")*3;

easeTimeSpan = 6;

easeOutSpeed =thisComp.layer("controls").effect("SwayEaseOut")("Slider");

easeOutVal = easeOut(time*easeOutSpeed, 0, easeTimeSpan, swingMaxDistance, 0);

Math.sin(time * swingSpeed) * easeOutVal + transform.rotation;

I have a feeling this expression is far more complex than needed which is why I assume I had pieced it together during my run of all-nighters working on this project.  Boy did I re-learn a lot about math which I never thought would be useful in the "real world!"  In the above expression I thought I could link the easeOutSpeed to a slider which I could adjust but it's not working...

Thank you very much for your help!  I'll begin looking into the random seeds idea to see just how that works.

Any thoughts are appreciated!

-Stephen

Translate
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
Participant ,
Mar 10, 2013 Mar 10, 2013
LATEST

Well, I'm getting closer but I'm not there yet.

I found out how to use this expression which seems to do what I want but only for a single object sway.  If I could randomize this and put it on all of the items it would be pretty close.  Here's the expression:

Math.sin(time*2)*1;

This has two problems.  First it appears to start  swaying at the begining of the comp instead of the comp starting with the object already swaying.  I might be wrong on this.

The other problem I already mentioned.  I don't know how to randomize this so each additional object has a random sway.  I at least found out how to attach the stay to a slider:

Math.sin(time*2)*thisComp.layer("new slider control").effect("SwayAmmount")("Slider");

I am able to set the slider at 1 and then to stop it I set it to 0.  I don't think this has a real ease or inertia, but it's ok I guess.

But again, no random options.  I've searched high and low to understand the random function.  I found: "random()" but I need it to freeze at a random number.  I found "seedRandom(x,true)" but all directions I can find for that talk only about possition in the comp.  I've given up trying to translate this from position.

Here's the closest I've come, but honestly I'm not even sure that it's a real function...

seedRandom(3,true);

RanNum = random(-2,4)

Math.sin(time*(RanNum))*thisComp.layer("new slider control").effect("SwayAmmount")("Slider");

This again links to the slider.  It DOES randomize somewhat and is better than nothing.  But surely there is a "correct" way which I am completely overlooking.  Using this method all layers sway left to right (fairly similarlily).  I would love to have some begin right to left, random...

Any thoughts?

Thanks!

-Stephen

Translate
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