For sure!
There are a lot of ways to accomplish this in Unity.
I am going to assume that you are making a 3D experience and using RigidBody components.
FixedUpdate is a special method that Unity calls every 20ms - no matter what is going on with rendering, or performance - this is so you can do you physics simulations reliably and smoothly.
Remember the classic formula: rate * time = distance?
private void UpdateRigidBody()
{
Vector3 targetDestination = Vector3.MoveTowards(transform.position, destination, speed * Time.deltaTime);
var rb = transform.GetComponent<Rigidbody>();
rb.MovePosition(destination);
}
Where speed is calculated and with destination set on the object (below).
In your case, you know the distance (destination - current position), and you know the time = 2 seconds.
Your unknown is the rate (speed).
Speed = distance / time.
So you will need some other function to setup the movement - like ChaseTarget?
private void ChaseTarget(Vector3 target, float timeToReach)
{
destination = target;
var distance = (destination - transform.position);
speed = distance / timeToReach;
}
So, somewhere in your game controls logic you would call ChaseTarget and give it a target (a Vector3) and a time to get there. You setup these member variables on your object (targetDestination and speed) and the UpdateRigidBody function will smoothly get you there.
Typically, when you are close enough to the target you do some sort of new game logic and then reset the target destination (inside of UpdateRigidBody:
var destXZ = destination;
var posXZ = transform.position;
var dir = destXZ - posXZ;
var arrived = dir.magnitude < arrivedRadiusMagnitude;
if (arrived) // If I have arrived
{
Arrived();
}
Where the arrivedRadiusMagnitude is a game design question of how close can something get before it is considered arrived? For example some sort of tracking missile might explode when it is near a target, not necessarily right on top of it.