• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Better way of doing constraints

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

2 replies to this topic

### #1CryoGenesis  Members

Posted 08 September 2012 - 02:55 PM

Hey, I'm making my first proper 2D physics engine (I guess a kind of right of passage).

I've started by doing vector to vector constraints.
It works at the moment but it uses a kind of Master/Slave thing where one vector can move and move the other but when the slave vector moves it doesn't move the master (like a pendulum).
Here's the code:

//Finds out the angle between the vectors
angle = 90 + a.getAngle(b);

//Positions accordingly

Anyway of making it so they move each other?

### #2wildbunny  Members

Posted 10 September 2012 - 11:19 AM

Hi there,

Sure, you need to design your constraint so it works in 'relative space' and pushes on object A while pulling on B.

I wrote just the article which should help you out with understanding how to design a constraint:

http://www.wildbunny.co.uk/blog/2011/04/06/physics-engines-for-dummies/

It starts off dealing with simple concepts and builds up to designing a constraint

Hope that helps!

Cheers, Paul.

### #3CryoGenesis  Members

Posted 11 September 2012 - 11:29 AM

Thanks! took so long to get an answer. +1rep:)

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.