Jump to content
Search Community

Advice regarding continuous ever changing motion

samueljonasson test
Moderator Tag

Recommended Posts

Hi,

 

I am struggling to get smooth tweens for a project I am currently working on. I was hoping someone here could give me good advice. I am a proud Greensock member so I have access to all the plugins - if they would help.

 

A short explanation of my project: This is an interactive installation for a museum where the user moves a tangible object ( A ) along a pipe that spans the width of 4 x 40" monitors that are above the pipe. As the user moves the object on the pipe I need graphics ( B) in the monitors to follow the object. So in simple terms, the x value of A needs to match the horizontal position of B on the pipe.

 

I have a sensor that detects the position of A and sends it to my Flash project. The sensor is pretty slow and can only send me new values every second. So every second I get a new x value for A and then I need to tween B to that position. So it is actually an endless tween.

 

I have not been able to do this so that the animation feels smooth and seamless. I have tried to use updateTo() and I have tried the dynamicProperties plugin. I always end up with a very visible change in velocity every second when I get a new value.

 

Are the any known "tween design patterns" for this situation?

 

Best,

Sammi

Link to comment
Share on other sites

Sorry for the late response, this one somehow went under my radar yesterday.

 

That sounds like a really interesting project. I think what will help is to use tweens that move at a constant speed. So instead of giving each new tween the same duration, you calculate the duration based on how far the object needs to move.

 

 

take a look at my TweenLite Tweens with Constant Speed Demo:

http://www.snorkl.tv/2010/11/tweenlite-tweens-with-constant-speed-independent-of-distance-traveled/

 

every time you click on the swf you can imagine your sensor in Object A sending your flash movie the new x pos to tween to.

 

hopefully that helps

Link to comment
Share on other sites

Hi,

 

thank you for your advice and you are right - most likely I will have to use constant speed. I had actually implemented a constant speed solution without using a tweening engine. I just felt that the motion lacked some elegance.

 

Maybe there is no way to have smooth easing on an ever changing x target. Especially in this case because I do not want the gfx to "overshoot".

 

Thanks again. I will investigate how I can maybe use a constant speed solution but on every new value received from the sensor I can maybe do some logic that decides if I will move to next target at constant speed or a tween.

 

Best,

Sammi

Link to comment
Share on other sites

Actually, if your goal is to prevent there from being a noticeable (jarring) change in velocity, you might want to try out ThrowPropsPlugin. The name is somewhat deceptive because it's not really just for throwing. It basically allows you to tell the tween what velocity it should start out at and it will do all the fancy math behind the scenes to honor that and yet get you to your destination value smoothly. You'd need to manually keep track of your object's velocity so that you could feed the appropriate value to the new tween whenever you create one. There is sample code for dragging on the ThrowPropsPlugin page, and you'd do the same concept except that instead of the user dragging to create the motion, you'd have another tween performing the motion. Very little difference, really. Just a few tweaks to the code.

 

http://www.greensock.com/throwprops/

 

(the sample code uses BlitMask too, but you don't need to do that - it's totally optional).

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...