# Getting one rigidbody to follow another, but still react to stuff Unity3D/C#

Basically what I'm doing is having a ball you can pick up and drop on a ramp. When you pick up the first ball, the second ball follows close behind, and when you drop the first ball on to the ramp the second ball drops on to the ramp as well, rolling down and launching off. The second ball continues to follow the first through the air.

How could I go about getting the second ball to follow the first, while still keeping the rolling-gravity effect?

Thanks.

• Should it flollow like a ghost with identical movement or with own physical movement? Commented Apr 17, 2012 at 7:05
• Basically, I want it to follow as if it was "holding on" to the second ball. Think of it in human terms: A helicopter lifts one human, and another human grabs on to the first human's leg. Commented Apr 17, 2012 at 19:14
• In this case the spring-joint solution mentioned by Gajet is most probably the way to go. Commented Apr 18, 2012 at 10:13

I'm not sure but maybe you can connect both balls with an spring. if you don't want those two to change their distance you can put a very high value for spring constant. although this way the second ball also will effect on the first ball movement.

• This is how I'd start to go at it.
– Esa
Commented Apr 17, 2012 at 5:04
• This spring idea may very well work, I'll have to test some variables and adding/removing the spring joint via code, we'll see if it does. Commented Apr 17, 2012 at 19:34
• Thanks a ton! This worked, by adding and removing a springjoint I can make one follow the other, and still be affected by physics. Commented Apr 17, 2012 at 20:12

As I understand it you want the second ball to follow in the same path as the first ball while you carry the ball around, and then after that be affected by physics.

In this case you want to store the positions of the first ball in a list/queue and simply set the second balls position to these coordinates (ignoring physic responses) at a set distance, or set time, behind it.

For instance:

var path = new List<Tuple<TimeSpan, Vector3>>();

Then using Vector3.Lerp to set the position of the second ball, either calculating so its a certain time behind, or add up the distance in the path and find the position that is a certain distance behind the first ball.