Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Taylan

Get current position (percentage) of motionPath in onUpdate

Recommended Posts

You know how tween starts from motionPath.start and moves to motionPath.end? I want to get that changing value during onUpdate. Even if there is no way to get that value as is maybe I can calculate it? Are there helper functions like getPositionInPath(object, path) / getPathLength(path)?

Link to post
Share on other sites

Hey @Taylan

 

I don't know if there is an easier way to do that, but in your onUpdate you could check on the progress of the tween and multiply it by the total-length of the path that is the basis for that scene.

 

Is that what you're looking for?

 

 

See the Pen rNLPbWd by akapowl (@akapowl) on CodePen

  • Like 1
  • Thanks 1
Link to post
Share on other sites

@akapowl It doesn't account for easing but unless I'm mistaken I can calculate correct value that accounts for both easing + different start/end values like this:

 

See the Pen pobGBWd by taylankasap (@taylankasap) on CodePen

 

Thanks!

  • Like 1
Link to post
Share on other sites

 

I am by no means an expert on this, but looking at the log, this seems to work pretty well.

Link to post
Share on other sites

@GreenSock It helps big time :) Is there a documentation for ratio (and maybe other properties of this)?

Link to post
Share on other sites
3 minutes ago, Taylan said:

@GreenSock It helps big time :) Is there a documentation for ratio (and maybe other properties of this)?

Sure, have you poked around the docs? Everything should be there. Here's the direct link to the ratio property of Tween instances: 

https://greensock.com/docs/v3/GSAP/Tween/ratio

 

Happy tweening!

  • Like 1
  • Thanks 1
Link to post
Share on other sites

 

17 minutes ago, GreenSock said:

Sure, have you poked around the docs? Everything should be there.

I did but I expected to find it on sidebar under Properties or under search results.

 

Thanks for the link.

Link to post
Share on other sites

Oh, that is odd that it doesn't show in the search results. We'll look into that. Sorry about any confusion there. 

Link to post
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.

×