The Daily Click ::. Forums ::. Klik Coding Help ::. Overlapping Object Multiple Collisions
 

Post Reply  Post Oekaki 
 

Posted By Message

»xerus



Registered
  28/06/2002
Points
  675

You've Been Circy'd!Game of the Week Winner
18th May, 2005 at 22:16:11 -

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?

 
n/a

Hernan



Registered
  04/03/2003
Points
  707

VIP Member
19th May, 2005 at 03:27:03 -

That's odd, I never had that. Which tool do you use, and can you show how you coded it?

 
This space is for rent

Nuutti



Registered
  26/10/2003
Points
  1364
19th May, 2005 at 08:12:01 -

Or:

Bullet is overlapping Enemy
-Spread value 0 in Bullets Alterable Value A
-Start loop "Testcollide" times: Number of bullets

On loop "Testcollide"
-Add 1 to Global Value A

On loop "Testcollide"
+Alterable Value Of Bullet=Global Value A
-Destroy bullet
-subtract 1 from enemy health

i'm not sure if it works..

 
P.S. sorry for my mangled english.

»xerus



Registered
  28/06/2002
Points
  675

You've Been Circy'd!Game of the Week Winner
19th May, 2005 at 16:06:12 -

I got it to work with fast loops.

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.

Thanks for the input.

 
n/a

Nuutti



Registered
  26/10/2003
Points
  1364
20th May, 2005 at 10:27:01 -

Yea 10 times fast loop doesn't slow down at all..

 
P.S. sorry for my mangled english.

Duncan

Thelonious Dunc

Registered
  18/05/2002
Points
  552

VIP Member
15th September, 2011 at 12:04:17 -

BUMP

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

 
n/a

Duncan

Thelonious Dunc

Registered
  18/05/2002
Points
  552

VIP Member
5th May, 2012 at 05/05/2012 18:12:56 -

^ Anyone?

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?

 
n/a

Jenswa

Possibly Insane

Registered
  26/08/2002
Points
  2670
6th May, 2012 at 06/05/2012 16:15:25 -

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.

 
Image

Duncan

Thelonious Dunc

Registered
  18/05/2002
Points
  552

VIP Member
6th May, 2012 at 06/05/2012 20:32:05 -

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
  5685

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
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.

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

Jenswa

Possibly Insane

Registered
  26/08/2002
Points
  2670
12th May, 2012 at 12/05/2012 13:41:00 -

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).


Edited by Jenswa

 
Image
   

Post Reply



 



Advertisement

Worth A Click