Handling collectible items

Spaddlewit
Posts: 28
Joined: Fri Sep 04, 2009 8:23 pm

Handling collectible items

Post by Spaddlewit »

I have a world with a LOT of collectible items (think like coins in Mario). What's the best way of representing these in bullet's world? Right now they are spheres with CF_NO_CONTACT_RESPONSE, but they still seem to be generating a lot of unnecessary manifolds and contact points, even when I am not touching them!
Megadanxzero
Posts: 13
Joined: Fri Sep 07, 2012 9:50 pm

Re: Handling collectible items

Post by Megadanxzero »

I would imagine the best thing to do would be to set the collision group and mask values when you add the objects to make them completely ignore everything other than the player, as I think CF_NO_CONTACT_RESPONSE simply prevents the object from reacting to collisions, but still checks to see if there actually is a collision.

Collision masks on the other hand are checked early on in the pipeline I believe, so if you had something like COL_COLLECTABLE and COL_PLAYER groups, you could make your collectables collide only with the player.
Spaddlewit
Posts: 28
Joined: Fri Sep 04, 2009 8:23 pm

Re: Handling collectible items

Post by Spaddlewit »

Turns out masks aren't all you have to do... I get fewer manifolds if I also toss out the collision if both objects have a linear velocity of zero. I'm surprised that bullet doesn't do this automatically for CF_NO_CONTACT_RESPONSE objects, but maybe there's a good reason...?