I would suggest you use (x,y,z) coordinate.

[img]http://www.phy.ntnu.edu.tw/demolab/phpBB/pics/2_2_collision2d.png[/img]

Assume and are center of those two balls. And the radius are .

Let which is the relative vector between two centers.

Collision occurred if the length :

The next step is to find two components of velocity vectors :

1. velocity components parallel to

The time step to move backward

Hints: how to calculate inner product

2. velocity components perpendicular to

The above two component will not change before and after collision

You can check out previous posted message. e.g. [url=http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=4.msg9#msg9]How to convert 2D collision into 1D[/url]

Just add one more component (z) if you want to transfer from 2D(x,y)to 3D(x,y,z).

It will be much easier if understand the meaning of inner product between two vectors- Help you find out projection of one vector into another vector.