How to move an object over a distance in a direction?

Hi.I just want to do a collision with spheres.I’ve got two spheres and one of them moving to the other. At the beginning there is a distance between them and let’s say the distance is 5.(Let’s say sphere1 and sphere2).And when sphere1 hits to sphere2,sphere2 must move 5 units only.And this collision must materialize according to physics rules.How can i do that?I tried a lot of things but i’m very new to unity 3D.Because of that i couldn’t find a way.Thanks for help.

Add a rigidbody to each of the spheres.
Make sure that both spheres have a collider component attached.
On sphere1, set the velocity of the rigidbody so that it moves towards sphere2.
When sphere1 hits sphere2, the collision will act according to the laws of physics.

I see 3 options depending on what product you want and what kind of solution you prefer:

  1. Physics - good for some game mechanics - easy to start at - hard to tweak/fix: Follow Ben’s approach and be aware that it will not 100% precise. A game physics engine is good at doing stuff fast and relative correct. It is not the best choice to simulate the law of physics in a precise way; this requires variable simulation steps.

  2. Animations - good for visual presentation - easy to tweak - not so flexible: Follow Berengers approach e.g. using the Animation window in the Unity Editor. In this you can move the 2 spheres according to a common time line.

  3. Code - expensive but flexible: If you can code scripts you can solve your problem in lots of ways.
    A code only solution is to encapsulate the behaviour of a sphere into a sphere script, add collision event handling (either by using colliders or math) and code the 100% impulse transfer as you want it to happen.

The best choice is dependent on your situation.