Jump to content
Search Community

My car is driving backwards! Flipping object on MotionPath

NickNo test
Moderator Tag

Recommended Posts

Ok, I'm a few days into playing around with gsap, and starting to really love it... getting stuck on a few things  - here are a couple I'd appreciate some help with...

I have an object on a path, but when I animate it, its upside down - I've tried a few things like trying to rotate in the .set() but that doesn't seem to work...is this something I can do in gsap, or should I do it elsewhere (css?).

 

 

 

 

The second question is about align:"self" using motionPath - I've read the docs and posts but still can't get my head around it - if I do the same animation, but with align:"self" I'm driving off the road - is "self" the path, or something else?

 

See the Pen wvMWMWY by nickjacobsnz (@nickjacobsnz) on CodePen

 

Thanks again:)

 

See the Pen abdZdmZ by nickjacobsnz (@nickjacobsnz) on CodePen

Link to comment
Share on other sites

Thanks Mikel,  the alignment issue makes more sense:

For the flipping of the car once its starts animating - I've fixed it by using "scaleY:-1,scaleY:-1" - I'm just trying to understand WHY that happens...?

Link to comment
Share on other sites

Hey Zach,

 

If I want to run an object from right to left, I could start the motion path on the right:

"the align property bends coordinate spaces in order to position the target exactly on top of the path."

But then the object is upside down.
So in this case I have to start the path on the left and use a from tween?

 

See the Pen RwrGKVP by mikeK (@mikeK) on CodePen

 

Kind regards

Mikel

Link to comment
Share on other sites

7 minutes ago, mikel said:

Why do I have to correct this here?

If you're asking why MotionPath does it that way is because it generally makes the most sense :) Most objects are oriented to go left right. MotionPath doesn't the capacity to visualize things the way humans do so we have to choose some way of orienting it. 

 

You can visualize the way that MotionPath sees the rotation by using a left-hand rule*: 

  1. Point the tips of your fingers (not thumb) at the starting point of the path.
  2. Close your hand towards the way the path is moving at the next point in time.
  3. Stick your thumb up - that's the normal rotation (i.e. autorotate: true/0).

Any rotation angle supplied by the user applied after that is determined.

 

* inspired by the right-hand rule of math/physics.

  • Like 2
Link to comment
Share on other sites

9 hours ago, ZachSaucier said:

If you're asking why MotionPath does it that way is because it generally makes the most sense :) Most objects are oriented to go left right. MotionPath doesn't the capacity to visualize things the way humans do so we have to choose some way of orienting it. 

 

Just a minor correction - MotionPathPlugin merely takes your path data and uses that, so if the path data goes from right to left, that's what MotionPathPlugin will do. And the rotation is measured based on the tangent at that specific point on the bezier path. 

 

Glad you found a solution!

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

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...