Better way of doing constraints,
Members - Reputation: 528
Posted 08 September 2012 - 02:55 PM
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);
b.x = a.x + distance*Math.sin(Math.toRadians(-angle));
b.y = a.y + distance*Math.cos(Math.toRadians(-angle));
Anyway of making it so they move each other?
Members - Reputation: 550
Posted 10 September 2012 - 11:19 AM
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:
It starts off dealing with simple concepts and builds up to designing a constraint
Hope that helps!