Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This question was closed May 25, 2012 at 11:10 PM by You! for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by You! · Mar 23, 2012 at 07:36 AM · javascriptmovementbeginnerlerpslerp

How to use Lerp?

I am confused on how exactly to use the Lerp function. I am using the function as Slerp in the following code:

example 1:

 selfplace.rotation = Quaternion.Slerp(selfplace.rotation,Quaternion.LookRotation(target.position-selfplace.position),MarManRotateSpeed * Time.deltaTime);

example 2:

 selfplace.rotation = Quaternion.Slerp(selfplace.rotation,Quaternion.LookRotation(target.position - selfplace.postition),MarManRotateSpeed * Time.deltaTime);
Comment
Add comment · Show 3
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 AlucardJay · Mar 23, 2012 at 08:22 AM 0
Share

Please dont post this question in other questions.

http://answers.unity3d.com/questions/230775/character-gravity-problem-character-flies-upward.html

If you are genuinely interested in Lerp , then I apologize .

avatar image You! · Mar 24, 2012 at 12:29 AM 0
Share

I created this question because, if you don't remember, @hijinxbassist suggested that I could create the question to both solve some of my problems and contribute to the community. Even if I do not need this for my project, I still want the reference for others to see.

avatar image cregox · Nov 22, 2012 at 08:55 PM 1
Share

I find this a great explanation: http://answers.unity3d.com/questions/14288/can-someone-explain-how-using-timedeltatime-as-t-i.html?sort=oldest

3 Replies

  • Sort: 
avatar image
4
Best Answer

Answer by Kryptos · Mar 23, 2012 at 08:18 AM

Lerp is a linear interpolation, whereas Slerp is a spherical interpolation.

In the first case, the interpolated point will 'move' from the first to the second argument along the segment formed by these two points.

In the second case, the interpolated point will 'move' from the first to the second argument along the sphere surface which center is calculated so that the first and second argument belong to the arc.

To learn more about Lerp, see http://en.wikipedia.org/wiki/Lerp_%28computing%29.

To learn more about Slerp, see http://en.wikipedia.org/wiki/Slerp

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 You! · Mar 23, 2012 at 11:41 PM 0
Share

Thank you for the clarification.

Also see @xtplpune's answer for a more technical description.

avatar image
1

Answer by xtplpune · Mar 23, 2012 at 08:42 AM

static function Lerp (from : float, to : float, t : float) : float Description Interpolates a towards b by t. t is clamped between 0 and 1.

When t = 0 returns from. When t = 1 return to. When t = 0.5 returns the average of a and b.

JavaScript // Fades from minimum to maximum in one second

var minimum = 10.0; var maximum = 20.0;

function Update () { transform.position = Vector3(Mathf.Lerp(minimum, maximum, Time.time), 0, 0); }

Comment
Add comment · Show 4 · 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 You! · Mar 23, 2012 at 11:41 PM 0
Share

Could you expand on this? What you are saying is vaguely understandable, but I am, for some reason, not completely understanding it. What exactly is a and b? Are they the $$anonymous$$imum and maximum, respectively? Does "clamped" mean changing between?

Thanks for the example script!

avatar image AlucardJay · Mar 24, 2012 at 03:11 AM 0
Share

This is just a copy from the Unity Script Reference : http://unity3d.com/support/documentation/ScriptReference/Vector3.Lerp.html

avatar image You! · Mar 24, 2012 at 08:08 AM 0
Share

I still can hope that he knows, can't I?

avatar image AlucardJay · Mar 24, 2012 at 08:31 AM 0
Share

yes, this was just a direct link to the reference for you.

avatar image
0

Answer by rain · Mar 23, 2012 at 07:44 AM

As far as i know, lerp/slerp must be called in every frame if you want effect.

Btw. are you sure that "selfplace.postition" is an existing property?

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 You! · Mar 23, 2012 at 11:33 PM 0
Share

I thought I fixed that... I'm changing that line to what it should be. Thank you!

Follow this Question

Answers Answers and Comments

8 People are following this question.

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

Related Questions

Make Lerp or other more fluid or continuous 3 Answers

Moving left and right in air. 1 Answer

How to move an object along the X and Z axis with arrow keys/wasd with javascript? 1 Answer

Slerp Problem?: Enemy in Constant Rotation! 1 Answer

Restricting Movement within a cover system? 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