- Home /
Object movement with smooth start and end?
I have a cube in the scene. Now I want to move this object from one vector3 point to another vector3 point with smooth start and smooth end movement.
I tried this:
transform.position = Vector3.Lerp(transform.position, randomPoint, speed * Time.deltaTime);
With this I have a smooth end movement, but not a smooth start movement.
I also tried Vector3.SmoothDamp(). Here is the same problem. There is only a smooth end movement.
Answer by HarshadK · Feb 05, 2015 at 02:27 PM
There are various solutions for this same issue on this Forum thread:
A smooth (ease in out) version of Lerp?
Also check out this Reddit thread for more details on this matter: Vector3.Lerp, slow in and out, and even translation.
Answer by carrollh · Feb 05, 2015 at 02:42 PM
I think what you want specifically is Mathf.SmoothStep applied to the 3 parts of a Vector3.
transform.position = Vector3(
Mathf.SmoothStep(transform.position.x, randomPoint.x, speed * Time.deltaTime),
Mathf.SmoothStep(transform.position.y, randomPoint.y, speed * Time.deltaTime),
Mathf.SmoothStep(transform.position.z, randomPoint.z, speed * Time.deltaTime));
Your answer
Follow this Question
Related Questions
Smooth translation 2 Answers
Vector3.Lerp Only working once 1 Answer
Vector3 Lerp using Time.deltaTime? 3 Answers
Vector3 Lerp finish too quicly 1 Answer
How to smooth my camera (Vector3.Lerp) 0 Answers