This project has moved. For the latest updates, please go here.

Body to follow a certain path

Topics: Developer Forum
Jun 7, 2012 at 2:36 PM

I'd like to have certain bodies in my world follow a specific path or movement if you will.  I know I can use waypoint logic for this type of thing, but my problem  is this specific path can be anywhere on the map.  Attached is an image of the movement i'm looking for.  The body should be able to make this type of movement starting from Vector(0,0) or from Vector(2567,345) or anywhere else in the world.  Any advice on this?

Jun 7, 2012 at 7:18 PM

The Path class can provide the control points of the curve and they can be translated, scaled and rotated as well to your liking. The waypoints as you call them would be then dependent on the velocity and the time step.  PathManager.MoveBodyAlongPath() could be of help. There is a sample in the TestBed.

Jun 7, 2012 at 8:07 PM

Isn't PathManager for ropes and bridges?  I'm not near my machine to play with test bed, but I wasnt aware that you can use it for what I am trying to do.

Jun 7, 2012 at 9:56 PM

It has some convenience functions that can be used for ropes and bridges (EvenlyDistributeShapesAlongPath(), AttachBodiesWithRevolute/SliderJoints()) but Path is basically a class encapsulating Catmull-Rom splines (a case of cubic Hermite splines) so good for anything. The difference with Bezier curves, which are another commonly used rappresentation,  is where the control points lie - in the case of Catmull-Rom they line on the curve  whereas in Bezier only the first and last lie on the curve. Thus Catmull-Rom is very commonly used in interpolation between keyframes where the control points are at known positions.