When two objects overlap and both collide with an object at the same time, it only registers once. For example, two bullets overlap each other exactly and collide with an enemy. If I wanted to subtract hp from the enemy by 1 every time a bullet hit, only 1 would be subtracted in this case. Is there any way to test for multiple collisions or somehow accomplish what I want to do?
Before it was just when bullet collides with enemy (Im using groups)
I changed it to on loop "something", when bullet collides with enemy, pick one bullet, and then always run the loop 10 times. It doesnt seem to slow down at all from this.
I'm trying to do this. I'd really like to know the secret differences between "Collision between..." and "is overlapping". Multiple instantaneous overlaps will only register once, but the collision event counts for each object.
That said, the collision event does inexplicable things. For example, if you do this...
Bullet collides with Group.Enemies
+ Group.Enemies Flag 0 is off [or any condition which multiple objects have in common]
---> Destroy Group.Enemies
... Then you'll destroy a) the object involved in the collision, and b) any different objects in Group.Enemies that also meet the second condition (but aren't duplicates of the object collided with). Obviously using overlaps on the other hand works fine.
As a quick and dirty workaround I'm using...
Bullet collides with Group.Enemies
+ Bullet is overlapping Group Enemies
+ whatever else
... And this seems to work, but it makes me wince a bit.
Couldn't find much of relevance searching TDC, but if there are any threads or articles I should study please post them my way, cheers
The flag switcheroo doesn't work; the "collision between..." condition is a unpredictable (see above - I eventually dropped the method I was using, I can't remember why, but I'm going to assume there were more problems); I tried using a foreach loop but the swf exporter decided this meant "do something completely inexplicable!"; using a "pick one of" condition in conjunction with a loop or duplicated events works perfectly but it seems so weird that I can't fix this without a loop.
Also - what about projectiles that aren't destroyed on contact? And they might overlap two objects at once, or two of them might overlap the same object?
Interesting, I've never encountered this bug or defect by design of tgf/mmf.
So the bullets overlap each other, do they have an event for this? That should clarify things.
Hmm well, I just created a testcase with some setups for colliding and/or overlapping and I haven't encountered your problem. I've two red blocks (the same object) which overlap each other and they collide with a green block. The green block receives +1 for it's hp counter (value A) on collision and the red blocks are destroyed. Both blocks get destroyed and the counter displays: 2.
But what Duncan is telling is true: collision counts for each object, but overlapping counts for all objects just once. And that's weird because they (the red blocks) do get destroyed but they just add 1 once to the counter and not twice. So the action on each object that is overlapping gets executed, but the action on the object that is being overlapped just once.
Lovely problem, I would like to know more about it too. But now I've to for dinner.
Thanks for checking it out Jenswa, hope you had a good dinner!
n/a
Assault Andy Administrator
I make other people create vaporware
Registered 29/07/2002
Points 5686
7th May, 2012 at 07/05/2012 09:32:48 -
I didn't read the whole post, but "On Collision" is handled differently to "overlapping". On Collision is uses default built in movements and doesn't work for custom movements, and a lot of other things because it triggers in different circumstaces (hence it is a red event). I personally use "Is overlapping" for all collisions.
Thought of a solution: write your own collision code for the bullets.
For example: check if the coordinates of the bullets are inside the (rectangular) area of your object.
Added after the edit:
Some little further experimenting delivered the following results:
1) Don't use "compare two general values" because once the conditions are met, the event is executed for each instance of the object! (In case of destroying: all objects are destroyed, and value adding just happens once, because the 'object' all instances is used (not sure if that all instances object really exists, but the results do).
2) Use the objects x and y position for collision testing through the object reference: X( "object" ). This way the conditions are tied to each of the instances of the object. (so not all objects are destroyed when one of the objects meets the criteria and value adding can happen multiple times).
One last note: tested this code with The Games Factory (not TGF or MMF TWO, but I think the results are transferable).