This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

  • 0
UnityGamesRoland

Interpolate between A and B value?

Question

Hey! I would like to interpolate value A to value B.

I know that it's basically a Mathf.Lerp, but the problem with this method is that it slows down towards the end. How can I interpolate the values without this slowing "effect" ?

Share this post


Link to post
Share on other sites

4 answers to this question

  • 0

how about:

Please login or register to see this code.

or

Please login or register to see this code.

 

Share this post


Link to post
Share on other sites
  • 0

To add to OMAs answer, if your wanting acceleration instead of deceleration, you can do exactly as OMA said but multiply it by an acceleration variable.

 

if(pos != dest)

{

accelVar = Mathf.MoveTowards(accelVar, 1, Time.deltaTime);

pos = Vector3.MoveTowards(pos, dest, speed * Time.deltaTime * accelVar);

}

else accelVar = 0;

Share this post


Link to post
Share on other sites
  • 0

I would like to recommend you a tool which helps quickly to rotate/move/scale a GameObject.

It works really fine. Take a look at this link - Please login or register to see this link. ++

Share this post


Link to post
Share on other sites
  • 0

Lerp is meant to used like this:

Please login or register to see this code.

 

1 person likes this

Share this post


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