Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
    
Should it flollow like a ghost with identical movement or with own physical movement? –  jonas Apr 17 '12 at 7:05
1  
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. –  Timothy Williams Apr 17 '12 at 19:14
    
In this case the spring-joint solution mentioned by Gajet is most probably the way to go. –  jonas Apr 18 '12 at 10:13

2 Answers 2

up vote 4 down vote accepted

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.

share|improve this answer
    
This is how I'd start to go at it. –  Esa Apr 17 '12 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. –  Timothy Williams Apr 17 '12 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. –  Timothy Williams Apr 17 '12 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>>();
path.Add(Tuple.Create(gameTime.TotalGameTime, ball1.Position));

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.