Hi,
I'm currently using the following to set up a prismatic joint:
b2PrismaticJointDef jointDef;
jointDef.collideConnected = true;
jointDef.Initialize(Body1, groundBody2, Body1->GetWorldCenter(), worldAxis);
_World->CreateJoint(&jointDef);
where worldAxis is initially equal to 0.0f, 0.0f.
This works fine; I get a sprite (Body1) that moves along one axis.
What I want to do next is allow the user to change the axis at any given time (when they click on a button). So, for example the axis is initially horizontal, the user presses a button and the axis is now vertical. Basically, update the worldAxis value.
Redoing the initialization with the new worldAxis figure does nothing. I've looked at the manual and have tried a few things:
1 - changing jointDef.localAxis1
2 - doing a settransform: Body1Body->SetTransform(Body1Body->GetPosition(), 0.5f);
3 - changing jointDef.referenceAngle
while they all updated their values to the new axis, nothing actually happens with Body1, it always continues along the initialized axis.
So i can set the initial axis but I don't know how to update the axis.
I'm new to Box2D and don't really know what I'm doing in certain areas, such as this. Can someone help me? Thanks in advance....
I'm currently using the following to set up a prismatic joint:
b2PrismaticJointDef jointDef;
jointDef.collideConnected = true;
jointDef.Initialize(Body1, groundBody2, Body1->GetWorldCenter(), worldAxis);
_World->CreateJoint(&jointDef);
where worldAxis is initially equal to 0.0f, 0.0f.
This works fine; I get a sprite (Body1) that moves along one axis.
What I want to do next is allow the user to change the axis at any given time (when they click on a button). So, for example the axis is initially horizontal, the user presses a button and the axis is now vertical. Basically, update the worldAxis value.
Redoing the initialization with the new worldAxis figure does nothing. I've looked at the manual and have tried a few things:
1 - changing jointDef.localAxis1
2 - doing a settransform: Body1Body->SetTransform(Body1Body->GetPosition(), 0.5f);
3 - changing jointDef.referenceAngle
while they all updated their values to the new axis, nothing actually happens with Body1, it always continues along the initialized axis.
So i can set the initial axis but I don't know how to update the axis.
I'm new to Box2D and don't really know what I'm doing in certain areas, such as this. Can someone help me? Thanks in advance....