Hello! First of all thanks for the awesome physics engine!
I was wondering if b2Contacts survive from BeginContact to EndContact and if there addresses in memory stay the same throughout that process.
The reason I ask is in my game I am using a "state" system where I change the states of my characters and run game logic depending on what state they are in or have been changed to.
For example:
In presolve a character's state is changed to stateCollision because it collided with an object
The game then plays a collision sound.
(here's where it goes wrong)
In pre solve the same contact with the same object is being handled and it changes the characters state to stateCollision again.
The game then plays the collision sound again.
So I tried this:
Code:
-(void) newState:(States)state withContact:(b2Contact *)contact {
if (contact != _prevContact) {
[self newState:state];
}
_prevContact = contact;
}
The contact listener sends this message with the b2Contact involved to the character then the character checks the see if the address of the new contact is the same as the old contact, which I thought would prevent the same collision from changing the characters state multiple times. But it isn't working so far and I was wondering if b2Contacts have unique memory address and if they survive from beginContact to endContact?
Thank you!
Marc