Hello, I’m trying to create an interaction system similar to the one in Amnesia the dark descent. In the game when you pick up an object it will follow your cursor around while still behaving like a physics object. I have tried recreating that in unity using conventional merhods such as simply setting the position of the object directly and setting the velocity of the rigidbody, but I’ve found that when the object is blocked by an obstacle it will try to move through it ignoring any colliders. Using Addforce I dont have that problem since I’m not setting the position of the object directly. But the problem i do have is that the object will overshoot the empty gameobject I set as the position where i want the held object to be, because it’s adding force in the direction of the empty continuosuly. I’m looking for a solution where the held object smoothly moves to the position of the empty gameobject using Addforce, maybe applying a counter-force that slows the object down on arrival?

Found the answer, you apply a force in the opposite direction.

I somehow managed to make an equation that gives me the amount of force i need to apply in order to smoothly stop the object at the cursor, and when i plugged that into unity it worked.

Here it is, hope its clear enough:

**s** = distance ; **v** = velocity of object ; **V** = velocity but as a vector, since we need a direction as the end result ; **m** = mass of object ; **F** = force required to stop ; **t** = time until stop

**a** = acceleration.

We want **F** and **F = ma**, we know **m** (from the rigidbody) and **a = v/t** and we know **v** (same, from the rb)

Now we just need the **t**:

Since: **s = vt/2** → **t = 2s/v** (again we know the v, and we know s by using the Vector3.Distance func)

So: **F = (mV)/(2s/v)**

There, we could simplify it more but eh it works. Of course we apply the negative amount of force we got because its in the opposite direction.

In code, like I said, we can reference everything:

**m** = rigidbody.mass ; **v** = rigidbody.velocity.magnitude ; **s** = Vector3.Distance(Pos1;Pos2)

Idk if anyone else ever will need this but whatever, I thought since I asked a question and found the answer to it why not post it as well