First attempt of b2PrismaticJoint

Hi, I am attempting to create a prismatic joint for the first time. The Joint itself seems to work (i think) but I have a problem with limits. When I set up a upper limit and add some motor speed the body rises as expected. But it never stops even when it reaches the upper limit.

Firstly, should this stop automatically if the joint is set up correctly?
Second, how do I check if the upper limit has been reached? Inside b2PrismaticJoint.cpp I can see that the lines
Code:
         if (m_limitState != e_atUpperLimit)
         {
            m_limitState = e_atUpperLimit;
            m_impulse.z = 0.0f;
         }


are run but I don't understand how I can get hold of the m_limitState as this is protected.

Any help would be great.
Thanks
Did you set the lower and upper limit and enable the limit?
Thanks for the reply. I managed to get it sorted and it's because I didn't specify the density, friction and restitution of the body. Doh!

Now that I've managed to get the joint working I've used it to create a pressure plate on the ground. When a body hits the joint it acts like a button. The problem I have now is that I have two body types: Circle and Box. I would like only Box to have enough force to press the "pressure plate" prismatic joint. The Joint, Circle and Box bodies are set up as follows:

Circle Fixture (very small density as I don't want this to affect the joint)
Code:
b2FixtureDef ballShapeDef;
ballShapeDef.density = 0.01f;
ballShapeDef.friction = 1.0f;
ballShapeDef.restitution = 0.0f;


Box Fixture: (large density as this should always have enough mass to press the button)
Code:
boxShapeDef.shape = &screenBox;
boxShapeDef.density = 100.0f;
boxShapeDef.friction = 0.7f;
boxShapeDef.restitution = 0.0f;


Joint Definition:
Code:
b2PrismaticJointDef jointDef;
b2Vec2 worldAxis(0.0f, 1.0f);
jointDef.Initialize(_btnBase.body, _body, _btnBase.body->GetWorldCenter(), worldAxis);
jointDef.enableLimit = true;
jointDef.lowerTranslation = 0.0f;
jointDef.upperTranslation = 0.1f;
jointDef.maxMotorForce = 30.0f;
jointDef.motorSpeed = 15.0f;
jointDef.enableMotor = true;
[GamePhysics getWorld]->CreateJoint(&jointDef);


This seems to work fine between the joint and Box but the joint and Circle has a problem. The joint has too much force and causes the circle to be catapulted into the air when it hits the joint. I've tried various combinations but cannot seem to get this to work as required. I set the restitution to 0.0 in case this caused the rebound.

Is this suitable for prismatic joint or am I going about this the wrong way?
Thanks.
That looks reasonable. Don't mark the ball or plate as a bullet. You can try reducing the motor speed.

Original thread: https://box2d.org/forum/viewtopic.php?t=6628