Also, I'm a little bit confused, as to which object is A and which object is B? Which one is stationary, and which moves along right axis?
The line is attached to entity A, and a point which is held on that line is attached to entity B. If both entities are dynamic, both can move along the line relative to each other. Actually watching the simulation makes this more understandable.
Ok, so what can I use as the second entity? The room is static, and isn't an Entity.
Passing in null to a constraint constructor will make it connect to a special kinematic 'world' entity. Be careful about which connection is null, though; in this case, since the line is attached to entity A, it is probably most intuitive to pass null for entity A. So:
Code: Select all
var b = new Box(new Vector3(4, 5, 5), 1, 1, 1, 10);
PrismaticJoint prismaticJoint = new PrismaticJoint(null, b, b.Position, Vector3.Right, b.Position);
//Activate the limit so that the boxes can't fly infinitely far apart.
prismaticJoint.Limit.IsActive = true;
prismaticJoint.Limit.Minimum = 0;
prismaticJoint.Limit.Maximum = 4;
Space.Add(b);
Space.Add(prismaticJoint);
Try plopping it into a BEPUphysicsDemos demo
