Stopping collision after the first collision
aganguly
Member Posts: 22
In my game I make the user proceed to the next level only when say game.hits = X, where X can be 1 to n..
Now, I have two actors.. (say A and ..When B collides with A, the game.hits is incremented by 1 and both basically fall off to the bottom of the screen. Now, the issue is that when both fall off there are situations where in both of them collide again ( thus increasing the hits by 1 ). I however, want the hits attribute to increment only when both of them collide in the air. Also, if I purposefully fire actor B towards a previously "grounded" actor A, then also due to the collision rule, the hits attribute is incremented.
I could have destroyed either one of them to get rid of this problem, however, I do not want to do so..Is there a good way to handle this , that is, to stop the collision between them..
Now, I have two actors.. (say A and ..When B collides with A, the game.hits is incremented by 1 and both basically fall off to the bottom of the screen. Now, the issue is that when both fall off there are situations where in both of them collide again ( thus increasing the hits by 1 ). I however, want the hits attribute to increment only when both of them collide in the air. Also, if I purposefully fire actor B towards a previously "grounded" actor A, then also due to the collision rule, the hits attribute is incremented.
I could have destroyed either one of them to get rid of this problem, however, I do not want to do so..Is there a good way to handle this , that is, to stop the collision between them..
Comments
in the actor that has the collision rule make an attribute - Boolean and call it "collided" -set to false
then wrap the collision rule in a bigger rule like so :
*********************************
When "collided" is FALSE
When actor A collide with B
---- do what you want.
---- change "collided" to true
*********************************
This way after the first collision it will not collide again ,
you need to reset "collided" to False if you want it to collide again later.
Hope it helps.
Roy.
I somehow overcomplicated things by trying to avoid putting the above rule on the each instance of the actor A. Actually actor B does have the ability to strike multiple Actor A, hence, now I am forced to unlock and implement the rule at each instance of the actor...Actor A is all over the place in a given screen :-(