PDA

View Full Version : onCollisionExit triggers without reason on cards



vert1gus
12-29-2017, 08:57 PM
I am trying to keep track of which cards are touching which other cards on my table (I'm implementing Innovation).

To keep track of the color stacks, my cards use object scripts to log any touching between them. The onCollisionEnter works well, triggering whenever I drop a card so that it touches another (and each card adds the other into its internal list of touching cards).

The problem is the onCollisionExit. As long as I drop the cards so that they overlap only a tiny bit (img 1), both enter and exit (img 2) work fine (see chat log in images, relevant sections highlighted right after action taken). EDIT: Erm, didn't realise the image quality would be so low, you can't really read the text there. Suffice to say, the text log shows pretty much what I described in this post.)

But as soon as I drop the top card so that it covers the bottom one by 50% or more overlap (give or take, I'm just eyeballing this part, see img 3), the onCollisionEnter triggers followed immediately by the onCollisionExit, meaning each card adds and then scraps the other card from its touching list, while the two cards are quite obviously still physically touching in the simulation.

Is there something about the collision modelling on cards that I'm misunderstanding here? Are they supposed NOT to be seen as touching when the top card rests entirely on top of the bottom card without touching the table with its outer edge? (Note that I'm not talking about creating decks here; at no time am I dropping a card directly on top of another to create a deck).

Thanks for any input. This has been hounding me all day. :mad:

EDIT: I saw a related post after posting this suggesting this might have something to do with the physics mode (http://www.berserk-games.com/forums/showthread.php?4428-onCollisionExit-not-working-as-expected). I am currently in full physics mode, however, and this is still happening...

818819820