I've put up a demo app with static geometry and a basic sphere that moves around using WASD, that's all fair and simple but now I'm trying to fire projectiles from the sphere onto other objects. Projectiles in the game are handled in 2 ways. A sniper kind of weapon that does a raycast to determine if it hit an enemy. And all the other weapons will use sphere's as projectiles that move at slower speeds (not instant).
My problem is when shooting projectiles I would like to get more information on the object that it has collided with, when doing this:
Code: Select all
const int manifoldCount(m_dispatcher->getNumManifolds());
for(int loop = 0; loop < manifoldCount; loop++)
{
const btPersistentManifold *mf = m_dispatcher->getManifoldByIndexInternal(loop);
const void *obja = mf->getBody0();
const void *objb = mf->getBody1();
if(obja == moveableBall || objb == moveableBall)
{
// This manifold deals with the btRigidBody we are looking for.
// A manifold is a RB-RB pair containing a list of potential (predicted) contact points.
const unsigned int numContacts(mf->getNumContacts());
for(int check = 0; check < numContacts; check++)
{
const btManifoldPoint &pt(mf->getContactPoint(check));
// do something here, in case you're interested.
}
}
}
For example I want to know when rockets collide with walls, characters, floor, etc. When rifle rounds collide with wall,characters...
Does anyone have a recommendation or any idea on how I could put this together?
Thank you very much,
Luis Lairet