I need to know when a bullet and a player have contacted. This is the code i am trying to use. The problem is, i get a "access violation reading location 0x000000" error for any collisions, like bullet and wall.
class MyContactListener : public b2ContactListener { void BeginContact(b2Contact* contact) { //check if fixture A was the player or Bullet void* bodyUserDataA = contact->GetFixtureA()->GetBody()->GetUserData(); void* bodyUserDataB = contact->GetFixtureB()->GetBody()->GetUserData(); if( static_cast<GameObject*>(bodyUserDataA)->GetGameObjectType() == GOT_PLAYER ) // fixture A is a player { if( static_cast<GameObject*>(bodyUserDataA)->GetGameObjectType() == GOT_BULLET )// fixture B is a bullet { static_cast<Player*>(bodyUserDataA)->InflictDamage( static_cast<Bullet*>(bodyUserDataB)->damage ); } } } };