Replace Vector3.Lerp with something equivalent for rigidbody2D !!
Hey , so i have a ball Falling ( i tried many ways and all interpolation mode)
Also this ball are affected by a script which move it according to the position of the mouse only on x axis . Here is the script !
targetPos = new Vector3 (Input.mousePosition.x, Input.mousePosition.y, distance);
targetPos = Camera.main.ScreenToWorldPoint (targetPos);
Vector3 followXonly = new Vector3 (targetPos.x,transform.position.y, transform.position.z);
transform.position = Vector3.Lerp (transform.position,followXonly, speed * Time.deltaTime * 1.8f);
I already used this script but on objects that had no rigid body and it was smooth but now Probem is when the ball fall and i try to move it with the mouse on x axis with this script the ball movement become not smooth ! i have the impression that's shaking and slowing down
I have read many topic but i didnt found the solution ! maybe replace vector.lerp but with something which affect the rigidbody2D in the same way .
Thanks in advance !
Answer by meat5000 · Apr 08, 2018 at 05:44 PM
Vector2.Lerp. Maybe combine it with rigidbody2D.MovePosition
Or enable interpolation, as youve tried. This is the way.
https://docs.unity3d.com/ScriptReference/Rigidbody2D-interpolation.html
What's the way to do it Pleaze I didnt understand too much ? Give me the equivalent code of $$anonymous$$e with what youa re meaning
Your answer
![](https://koobas.hobune.stream/wayback/20220612160331im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Rigid body vibrating? 0 Answers
DOTween sequence snapping 0 Answers
Rigidbody2D.MovePosition() doesn't do anything (but animations and transform.Translate() works) 0 Answers
How to make instantiated rigidbodies continue moving the in the same direction as destroyed object? 1 Answer
Trick to move a game object smoothly to left and right 0 Answers