Is there any way to generalize collision-triggered events?

Ok, so I’m practicing making a classic side-view space shooter (no scrolling yet lol) and one thing I’m noticing is that projectile collision events multiply like crazy because there doesn’t seem to be a way to make the same event handle several different types of colliding objects.

So I have to make a different event for every pair of possibly colliding objects (i.e. one event for “bullet_1 collides with enemy_1” another one for “bullet_2 collides with enemy_1”, another one for “obstacle collides with enemy_2”, etc.

Is there any way around this? Can I make some sort of general cases?

If there isn’t, could I at least consolidate them into fewer blocks via OR conditions? Like:

if:
bullet_1 collides with enemy_1 OR Bullet_1 collides with enemy_2
then:
fuck up bullet_1, fuck up enemy_1, fuck up enemy_2

And the ones not involved in each particular triggering would be ignored?

You can just put all bullet in to a group and all enemies in to a group and then just say:

Condition:
‘BulletGroup’ is in Collision with ‘EnemeyGroup’

Action:
Delete object ‘EnemyGroup’

In case different type of bullets cause different damage for different type of enemies, you can store the values in object variables like damage of bullet and health of enemy and you can take those in to account also by referencing the group.

Condition:
‘BulletGroup’ is in Collision with ‘EnemeyGroup’

Action:
Do - BulletGroup.Variable(damage) to variable “Health” of EnemyGroup

Condition:
Variable ‘Health’ of EnemyGroup <= 0

Action:
Delete object “EnemyGroup”

It should pick only those objects and their variables from the group that is involved in the collision and meet the conditions.

1 Like

Groups? How do I set that up? How have I missed it?

I’m storing life on enemies, and I’m also doing a double check on collision (The bullets lose one life on impact on their own, and the enemies tell them that they’re spent when everything that needs to happen on their side does, that way if I forget to account for something, the bullets lying around let me know when trying it out.

I just have no idea how to access this group feature!

3rd button on the top:
Selection_008
Described on the wiki how to use it:
http://wiki.compilgames.net/doku.php/gdevelop5/objects/base_object

Search for “object group” on the page.

Unreal 2004 announcer:

S-S-s-solved issue!