Object collision with itself

1 favourites
  • 6 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • So I'm using a single object for each unit in a strategy game, using local variables to distinguish the team. I need a method to determine if it is overlapping another object of itself, but only if that object belongs to the other team. I'm not sure how to test this specifically.

    For example, I need:

    If unit with team = 1 collides with unit with team = 2, then trigger. This should be simple but the overlapping event is limiting me and I'm not sure what to incorporate to overcome this.

    Thanks!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • This has been brought up a million times and there has never really been a definitive solution. We desperately need some more options here! Ideally we could do something like...

    +If Instance (with value of x) collides with Instance (with value of y)

    -Pick Instance (with value of x) and do this

    -Pick Instance (with value of y) and do that

    You might be able to pull it off with functions or something but eh...good luck.

  • Could you just spawn an pin and invisible sprite over each team object. Team 1 gets invisible sprite 1 and team 2 get invisible sprite two and when the two invisible sprites overlap you you know its the condition your looking for?

  • This can be done with Families.

  • Yeah, just have sprite, put it in a family by itself, and give that family a variable named team. Now both sprite and sprite_in_family have the variable team and you can check if sprite is overlapping sprite_in_family and if sprite.team=sprite_in_family.team. I've got it working this way in my game Shards.

  • Alternatively you can use 'pick nth instance'. 0th and 1st instance can then be referenced individually.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)