• Advertisement
Sign in to follow this  

Constraints Between Two Entities?

This topic is 1968 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement