Temporarily disabling a RigidBody

Post Reply
User avatar
nikki
Posts: 22
Joined: Sat Jun 14, 2008 3:38 pm
Location: Doha, Qatar.
Contact:

Temporarily disabling a RigidBody

Post by nikki »

Hey guys!

For my next game, I'll be having a 'dimension' idea. Basically, there are two or more parallel worlds, and you can switch between them. The worlds are mostly the same, except there are a few differences, such as a wall in dimension 1 might not exist in dimension 2, and a switch might work in 2 while not in 1, and so on. The way I'll be handling this is having a property for each 'GameObject' (logic objects in my system) that shows which dimension it belongs to, and the GameObject accordingly makes itself known depending upon the global dimension.

What I was looking for was a way to 'temporarily disable' a RigidBody, that is, no collision events, no physics handling (the object is 'there' but other objects don't collide with it) etc. without destroying it.
jcrada
Posts: 11
Joined: Thu Oct 09, 2008 10:59 pm

Re: Temporarily disabling a RigidBody

Post by jcrada »

Hi,

I would try

Code: Select all

getRigidBody()->setActivationState(DISABLE_SIMULATION);
but I think that you have do the same to all the other rigid bodies it is connected to. I think that is called an island, so you must disable the whole island.

DISABLE_SIMULATION is defined in btCollisionObject.
User avatar
nikki
Posts: 22
Joined: Sat Jun 14, 2008 3:38 pm
Location: Doha, Qatar.
Contact:

Re: Temporarily disabling a RigidBody

Post by nikki »

Actually, after a little bit of though, I found that the actual way it should work would be that objects could continue to collide with objects in their dimension, and objects in both dimensions are affected by objects in both. I was able to get the effect I desired using collision filter masks.

Now, I have another question: Is it possible to change this mask after an object is created? It's required for the Player.

EDIT: I found a way: removeRigidBody and addRigidBody with the new dimension. Is this the right way to do it?
Post Reply