hoffhoff
12-11-2006 13:30:03
Hello,
I am trying to simulate de effect of a bomb. So, in the collision, it is supposed to "push" all objects near the collision point and then the bomb body is supposed to be deleted, because we donĀ“t need it anymore.
To do so, I am creating the userProcess function like this:
In the GameManager, I am doing it like this:
The "getPlayingPlayer" returns the pointer to the player that is playing in this turn. It has a pointer to the bomb he shot.
The "destroyBullet is just:
the destructor of m_pBullet is:
For testing, I put the method getPlayingPlayer->destroyBullet(); in the "f" key event too, and it works. I mean, if I shot and press "f", the bomb will disappear in the air.
But when I put the getPlayingPlayer->destroyBullet(); in the "explode()" function, it throws me an error in those boost files.
It looks like the "userProcess" is called many times, and then when the object is deleted, that function is still being processed, and then it crashes.
Do anyone has any idea of how can I do this?
Thanks!
I am trying to simulate de effect of a bomb. So, in the collision, it is supposed to "push" all objects near the collision point and then the bomb body is supposed to be deleted, because we donĀ“t need it anymore.
To do so, I am creating the userProcess function like this:
int boomwar::CContactCallback::userProcess()
{
if (m_ID == EXPLOSIVE_ANY) // pair between any material and an explosive one
boomwar::GameManager::getSingletonPtr()->explode();
return 1;
}
In the GameManager, I am doing it like this:
bool boomwar::GameManager::explode()
{
getPlayingPlayer->destroyBullet();
}
The "getPlayingPlayer" returns the pointer to the player that is playing in this turn. It has a pointer to the bomb he shot.
The "destroyBullet is just:
if (m_pBullet)
delete m_pBullet;
the destructor of m_pBullet is:
boomwar::local::CBullet::~CBullet(void)
{
if (m_pBody)
delete m_pBody; //it is an OgreNewt::Body*
}
For testing, I put the method getPlayingPlayer->destroyBullet(); in the "f" key event too, and it works. I mean, if I shot and press "f", the bomb will disappear in the air.
But when I put the getPlayingPlayer->destroyBullet(); in the "explode()" function, it throws me an error in those boost files.
It looks like the "userProcess" is called many times, and then when the object is deleted, that function is still being processed, and then it crashes.
Do anyone has any idea of how can I do this?
Thanks!