How to be sure, that collision will happen only once?

Almakos

  • Posts: 632
Hi,
I am checking whether two actors collide and then trigger an event. But sometimes I can see that event has been triggered several times during collision. What is the best way to read only first collision and ignore all following for collided couple?
Thanks.
Fishing Fantasy Trailer


hansbe

  • Posts: 262
Would you like to disable collision forever, or for a certain time ?

Ryusui

  • Posts: 827
Set a boolean to indicate the collision has happened and test for it.
In the event of a firestorm, the salad bar will remain open.

Innes

  • *
  • Posts: 1961
Set a boolean to indicate the collision has happened and test for it.


You can extend this by adding a timer to reenable the collision after x seconds if required.
Visit www.TheStencylBook.com - the only published book for learning Stencyl.

Almakos

  • Posts: 632
Would you like to disable collision forever, or for a certain time ?
In my case forever.

Set a boolean to indicate the collision has happened and test for it.
Will this work if I have multiple couples colliding almost at the same time?

You can extend this by adding a timer to reenable the collision after x seconds if required.
Not at the moment, but to think about it, It would be nice if I could freeze collided objects right at the point where they collided for some time. Is it possible? (I know that's a topic for separate post, but still, curious)

Thanks everyone for your replies.
Fishing Fantasy Trailer


Almakos

  • Posts: 632
Still something is wrong. that's how my blocks look like, but I get several YES\NO after one collision
If anyone can confirm that these blocks look OK, then I will move to other parts of game which could cause troubles.
Thanks
Fishing Fantasy Trailer


Sift

  • Posts: 47
You have set explosion to false on the outside of the if statement. Put it directly in the if statement to insure 1 collision.

Almakos

  • Posts: 632
You mean like this?
I've tried it before and it still prints out several YES\NO...guess I am missing something elsewhere..
Fishing Fantasy Trailer


Sift

  • Posts: 47
Print No and Yes are in the same if statement so when explosion equals true it prints both of them. If you put print No in the do after 1 second statement it will print no after one second.

Almakos

  • Posts: 632
got it to work finally. I know it is a bit of overkill, but now I will clean it up.
Thanks again!

« Last Edit: June 10, 2012, 11:49:48 am by Almakos »
Fishing Fantasy Trailer