Unity Rigidbody2D AddForce to move until certain position reached
Is it a way to use Unity Rigidbody2D AddForce to move until certain position reached? I wish to implement a knockback effect to a certain target Vector2 position for 2D game but I do not want the player to go to the target positon instantly.
I wish for a player to get pushed back to a target position with an animation.
The closest try I got is following:
void Update() { nextDistance = Vector3.Lerp(transform.position, targetPosition, knockSpeed * Time.deltaTime); stepDistance = Vector3.Distance(transform.position, nextDistance); transform.position = nextDistance; }
However, the player feels a bit glitchy and I wish for the player to be affected by gravity during the knockback.
Thanks very much
Your answer
![](https://koobas.hobune.stream/wayback/20220612152047im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Custom touch control stops abruptly! 0 Answers
How do I get objects in front of the player to be blasted away? 1 Answer
Issue with shooting projectiles in the direction of the arrow keys 1 Answer
Rolling platform affect player(ball) 1 Answer
How to make rigidbody not effect movement while still using it for collisions? 0 Answers