Hello everyone!
I am trying enabling and disabling a constraint so that I can enable it when a collision happens and disable it when the collision ends.
what better way to do this ?
I'm trying something like this:
if(colisao){ //creates a constraint
sphete.getBasis().setEulerZYX(0, SIMD_HALF_PI, 0);
palma.setOrigin(btVector3(0, 20, 12));
joitn6DOF = new btGeneric6DofConstraint(*bodySphere, *bodyPalma, sphere, palma, false);
world->addConstraint(join6DOF, true);
}else{ //When the collision ends
/* Delete constraint */
}
But the sphere and the hand do not been together when the collision happens. The sphere is spinning all the time and the constraint does not work...
Please someone helps me!
Thanks!
turning on and off one constraint
Re: turning on and off one constraint
Did you remember to set constraint limits/ motors?
-
- Posts: 21
- Joined: Wed Mar 25, 2015 2:04 pm
Re: turning on and off one constraint
Yes basroil, I added the limits... I can add a constraint at the moment that collision happens, but when the collision ends the constraint isn't removed...
- Erwin Coumans
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
- Contact:
Re: turning on and off one constraint
Did you use world->removeConstraint(...) ?
Re: turning on and off one constraint
In that case the code you posted isn't being clear about what you're actual code is doing. As Erwin said, if you want to remove the old constraint you'll need to explicitly remove it from the world, but none of that code was in your original comment.CarinaCruz wrote:Yes basroil, I added the limits... I can add a constraint at the moment that collision happens, but when the collision ends the constraint isn't removed...