How to move an object accurately while still being able to add physics to it?

Hi guys,

I’m very new to coding and for the past few days I have been struggling with a certain issue.
I’m trying to create a game where a sword object constantly follows the mouse, basically moving towards the mouse transform position and stopping when it reaches it. Also you should be able to add forces to the Rigidbody2D of the sword like when It bumps into a wall.

However Rigidbody2D doesn’t mix well with any of the means I know of moving an object towards a position (vector2.movetowards or Lerp). I tried making the sword follow the mouse using rigidbody physics but this just resulted in the sword always overshooting the mouse position once it had stopped moving or just in general being hard to control accurately.

Do you guys know any possible fixes for this issue or any other ways of going about this?
thanks in advance for the help. :slight_smile:

You can use Rigidbody2D.MovePosition method, see more here: Unity - Scripting API: Rigidbody2D.MovePosition