MoveTowards?

Been browsing the docs, and jerry-rigging a bit from the forums now, and can’t seem to get what I want, so I hope someone can answer this confusion, I am sure it’s super simple.

  1. I have an object in world space eg. (0,0,0)
  2. I have a script that detects mouse click position (world space)

Attempt I can move the object instantly, and the docs talk about moving between points over a specific amount of time, with smooth movement between them. But I am looking to not move between points on a given time, but at a given speed, no matter how long it will take to get there. So when I click somewhere, the object will start to move towards that target, at a given speed until it reaches it.

Put something like this in your Update():

transform.position = Vector3.MoveTowards(transform.position, v3TargetPosition, maxDistPerSecond * Time.deltaTime);

The MoveObject seem to be overkilling bambi, I used Robertbu’s solution and came up with this method, for future people who come across this. I have two variables, one for the target location and one for the current position. When I click somewhere, it sets the target location into that variable, and in the runetime update, it runs this:

if(myTransform != TargetLocation)
{
	transform.position = Vector3.MoveTowards(transform.position, TargetLocation, 2 * Time.deltaTime);
}

See MoveObject, specifically when using MoveType.Speed.