Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by TurboHermit · Jul 30, 2018 at 02:03 PM · animationtimelerppathlerping

Lerp waypoint path easing

Hey folks, I'm making a path animation tool using waypoints and I could use some help with the math. It's set up like this: you feed it a fixed amount of time for the animation to play and finish, for example 3 seconds. The script iterates through the waypoints (a vector3 array) and Lerps a transform between the current and next waypoint. The Lerp speed is calculated by dividing the total animation time with the distance between the designated waypoints, resulting in a constant speed over the entire array.

Now I want to use an AnimationCurve or any other slightly customizable method to easy the ENTIRE animation in and out. The problem is that an AnimationCurve works very well with a single Lerp as time value, but is harder to stretch over all these tiny Lerps which use a constant, calculated speed. Here's a snippet to give you an idea:

 currentSpeed = animationTotalTimeInSeconds / Vector3.Distance(path[currentPoint], path[nextPoint]);
 waypointTime += Time.deltaTime * currentSpeed;
 
 targetTransform.position = Vector3.Lerp(path[currentPoint], path[nextPoint], waypointTime);

Just multiplying the currentSpeed with an AnimationCurve.evaluate alters the SPEED, but I still want the total animation length to be the same, which is TIME.

Any ideas on how to fix this or faced a similar problem?

Thanks.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image TurboHermit · Aug 01, 2018 at 02:23 PM 0
Share

I just realized the animationTotalTimeInSeconds isn't even time in seconds but also some kind of speed. The case in which I was using it just happened to be around the same amount of time as I was putting in it.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bubinga_Studios · Aug 01, 2018 at 03:36 PM

Well Lerp is more of a position based timeline, so if you are trying to have a constant value, you may want to make your character look at the next point and move by a fixed amount of time using something like this.

 transform.LookAt(path[nextPoint]);
 transform.Translate(Vector3.forward * animationTime * Time.deltaTime);

I am having a little bit of trouble understanding your entire question, so if I didn't answer correctly, you can give me a bit more insight on your end achievement.

Hope this helps!


Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image TurboHermit · Aug 01, 2018 at 06:28 PM 0
Share

Hey thanks for your answer. I'm avoiding using Translate or $$anonymous$$oveTowards or any other movement method because I use Lerp info for other stuff as well.

$$anonymous$$y question has gotten a bit convoluted but basically what I'm asking is how would you smooth/ease a "speed" variable, but keep the entire thing a constant "time". It gets complex because it's multiple tiny Lerps that make up a single animation.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

232 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why do the numbers on the animation timeline jump from 0:10 to 1:00? 1 Answer

Animation Stop and Stay 1 Answer

Animation play 1 Answer

Animation play when player collides/hits an GameObject 0 Answers

Synchronize object positions 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges