Disable all Interactions from One Object

kulebril
Posts: 10
Joined: Wed Jan 16, 2013 1:36 pm

Disable all Interactions from One Object

Post by kulebril »

Hi!

I have a Ball with a sphere physic envelope, and a Character with a ghost capsule envelope.

When the caracter collides with the ball, I want the character to pick it a attach it to his hand.
The problem is, after picking it up, i get more collisions after the pick up.

I made a
Body->setCollisionFlags(Body->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE);

to try to disable the reactions while the character carries it, so I don't get more collision responses.

But as you can guess... the notifications are still there.

How can I make a body disable all reactions?

thanks in advance.


Yes, i'm quite sure is a noob question.
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Disable all Interactions from One Object

Post by Basroil »

You could always remove the object entirely and just recreate it when dropped, gets rid of trying to switch it from dynamic to kinematic and back (which seems to be what you are asking to do). Not necessarily the best way, but it is an option.
kulebril
Posts: 10
Joined: Wed Jan 16, 2013 1:36 pm

Re: Disable all Interactions from One Object

Post by kulebril »

I'm trying it, thanks!
kulebril
Posts: 10
Joined: Wed Jan 16, 2013 1:36 pm

Re: Disable all Interactions from One Object

Post by kulebril »

Hi:

But im not able to remove it from the collisionworld. If i do:

btRigidBody * rb=btRigidBody::upcast(btb->Body);

if (rb && rb->getMotionState())
delete rb->getMotionState();

this->phyWorld->removeCollisionObject(btb->Body);
this->phyWorld->removeRigidBody(rb);



it crashes when reached

phyWorld->stepSimulation(dt); //crashes on freealloc

how do you remove a body from the physic world?
kulebril
Posts: 10
Joined: Wed Jan 16, 2013 1:36 pm

Re: Disable all Interactions from One Object

Post by kulebril »

Hi!

I managed to get the object Out when picked up. And I'm able to put it again on the world. But the program crashes on some weird ways.

I was checking the possibility of using Collision Flags, in order to get the Ghost ignoring collisions with the wall till the proper time, but I really don't get how could I do it.


i have this flags

enum COLLISIONFLAGS
{
UNKNOWN =0,
FLOOR=1,
PLAYER=2,
BALL=4
};
ball->Envelope->Body->setCollisionFlags(ball->Envelope->Body->getCollisionFlags() | COLLISIONFLAGS::BALL);

if i do this, the ball loses interaction with the world, and stops falling by gravity.

How should I do this? I get the contact event and I have the moments in which I'd like the character to ignore collisions with the Ball, and the one in which I'd like to get them back.

Thanks in advance.