PDA

View Full Version : onCollisionEnter not triggering on multiple items?



Jabrwock
03-12-2017, 02:52 PM
I've got a bag of chips, and I'm currently using onCollisionEnter() to trigger a check of the colliding object to see if someone's trying to put a stack of chips in the bag using getQuantity().

Problem is, if I drop two stacks on the bag, onCollisionEnter only seems to trigger once, so it's only processing one of the items.

Is there a way to queue up the collisions so I can process them all?

two objects:

ba35f8
4e7278

code in bag:

function onCollisionEnter(collision)
obj = collision.collision_object
print('Collided with: ' .. obj.guid)
end

When I grab both stacks together (without grouping) and drop them on the bag, the log shows:

Collided with: 4e7278

MrStump
06-13-2017, 01:50 PM
This is because the other objects are not impacting the bag. You can, instead, do getObjects() on the bag any time onCollisionEnters to check the contents to see what has been added to it.