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
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?
Better way of doing constraints
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement