Started by Sep 02 2012 08:19 AM

,
3 replies to this topic

Posted 02 September 2012 - 08:19 AM

Hey I need some help.

How would you program constraints between two individually moveable objects? So one of the objects would move and it would consequently move the other object based on mass etc.

Do you subtract the velocity of each object? How would you make it so they rotate but are still constrained?

Any help +1 rep.

How would you program constraints between two individually moveable objects? So one of the objects would move and it would consequently move the other object based on mass etc.

Do you subtract the velocity of each object? How would you make it so they rotate but are still constrained?

Any help +1 rep.

Posted 02 September 2012 - 09:00 AM

Movement is always a vector, so you have a magnitude and a direction. Now you could be doing that by an x, y, z, magnitude. Since I don't know your exact code I have to just make some assumption.

There are three ways you can do this;

1. Assume they are connected by a bar, that would in most cases you just add the x, y, x magnitude change of object a to the connected object. For rotations, you would just object a as the center point of a circle and rotate it with the distance of the bar you made.

2. Assume they are connected by a rope. for magnitude changes it would be the same, for rotations, you would have to allow the object to come closer and whip around the object a. I haven't thought of exactly how to do the math.

3. Assume the are connected by a spring, this would mean object a would start to move before object b. Object b, would continue to move after object a stopped. Rotations would be a bit rope like with a delay.

There are three ways you can do this;

1. Assume they are connected by a bar, that would in most cases you just add the x, y, x magnitude change of object a to the connected object. For rotations, you would just object a as the center point of a circle and rotate it with the distance of the bar you made.

2. Assume they are connected by a rope. for magnitude changes it would be the same, for rotations, you would have to allow the object to come closer and whip around the object a. I haven't thought of exactly how to do the math.

3. Assume the are connected by a spring, this would mean object a would start to move before object b. Object b, would continue to move after object a stopped. Rotations would be a bit rope like with a delay.

Posted 02 September 2012 - 09:10 AM

I just thought of a fourth way, and the way that I would suggest. Use force. Instead of linking them directly, use force. Force = Gravitation Constant * mass object a * mass object b / distance between objects * distance between objects. Gravitation Constant is = 6.6726 x 10-11. That gives you the force acting equally on both objects. To get movement we use Force = Mass * Acceleration. So you take the Force / Mass and that tells you how much the object accelerates. Remember it accelerates in the direction of the other object.

If you need help with the basic code. Let me know.

If you need help with the basic code. Let me know.