Why do I need to * MoveTowards(...) by a negative number to actually get it to move towards something?

I’m trying to have an object approach the center of the screen (0,0,0) in bursts using using AddForce. This is how I got it to work:

IEnumerator MoveCenter(){
		while(!(transform.position == Vector3.zero)){
			rb.AddForce(Vector3.MoveTowards(transform.position,
											Vector3.zero,
											0.2f)*-rb.mass,
											ForceMode.Impulse);
			yield return new WaitForSeconds(0.8f);
			}
		yield break;
	}

Note line 5 when I say *-rb.mass.

If I multiplied MoveTowards(...) by a positive value, it would’ve moved away from the center of the screen.

What’s more it’s behavior doesn’t change whether or not I give MoveTowards a positive or negative delta. (e.g. Vector3.MoveTowards(transform.position, Vector3.zero, 1f)*<some positive value> by itself moves away from the target, and Vector3.MoveTowards(transform.position, Vector3.zero, -1f)*<some positive value>also moves away from the target.

I can only solve this by multiplying Vector3.MoveTowards by a negative value–a solution I only found by trial and error. What’s going on here? Why is this so contrary to what the docs say?

MoveTowards returns a point between the first argument and the second in 3d space, not a directional vector. Using the returned value to add force won’t produce any meaningful movement.

To give an example, say your transform’s position was at (10,0,0). if you call Vector3.MoveTowards(transform.position, Vector3.zero, 0.2f), the result should be (9.8,0,0), i.e. a point in space that is 0.2 units closer to the target (second argument) from the current (first argument). Your object will move away from the origin, as if this was interperated as a directional vector, it will be pointing away from Vector3.zero and towards your transform.position.

transform.position == Vector3.zero

The odds that your physics objects will just happen to land at the origin precisely, within fractions of a micrometer, are basically nill, so this will likely never become true. Instead, check if its within a certain distance from your target.

Here is a version that hopefully makes more sense:

 IEnumerator MoveCenter(){
     // do this until we are within 25cm of the origin
     while(Vector3.Distance(transform.position, Vector3.zero) > 0.25f){
         // this is a directional vector that always points towards 0, and is always 1 long
         Vector3 vectorTowardsOrigin = (Vector3.zero - transform.position).normalized;
         // force ammount (100f) may need tweaking
         rb.AddForce(vectorTowardsOrigin * 100f, ForceMode.Force);
         yield return new WaitForFixedUpdate();
         }
 }