b2PrismaticJoint body reach upperLimit

General discussion about the R.U.B.E editor
Post Reply
kotaiba
Posts: 2
Joined: Thu Sep 26, 2013 8:22 am

b2PrismaticJoint body reach upperLimit

Post by kotaiba »

Hi,
How can i get if Body reach the UpperLimit in prismatic joint ?
im using prismatic joint as button so if the prismatic joint reach the Upper limit that mean the button is not pressing , so im i doing it right or there is alternative way .
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: b2PrismaticJoint body reach upperLimit

Post by iforce2d »

You can use GetJointTranslation, as mentioned at the end of the section about limits here: http://www.iforce2d.net/b2dtut/joints-prismatic
  • Checking if a joint is currently at one of its limits is pretty simple:
    bool atLowerLimit = joint->GetJointTranslation() <= joint->GetLowerLimit();
    bool atUpperLimit = joint->GetJointTranslation() >= joint->GetUpperLimit();
kotaiba
Posts: 2
Joined: Thu Sep 26, 2013 8:22 am

Re: b2PrismaticJoint body reach upperLimit

Post by kotaiba »

thank you ..
Post Reply