On Collision Problem

0 favourites
  • 7 posts
  • I want to check the collision between 2 instance with variable Team. If they are not in the same team, the system should check the collision between different team but not the same team. Currently I have more than 10 teams.

    For example:


    Each Army has variable Team and the number in Team represent which team they are in. Lets consider there are 2 teams in this case.

    Picking the Team 1 before the On collision condition will filter out the Team 2 and vice versa.

    If pick all the teams the system will check the collision between Team 1 and Team 1. My game has 500 instances in each team and checking collison within same team will reduce the performace.

    Now I am jammed.

  • Create an instance variable "team" then you set a number so it tagged with a team number.

    In Events sheet:

    On collision with 'same object' AND team not equal to self.team >>> execute some action

  • The On collision condition will check the collison between the same team which will reduce performace, i need to pick 2 different teams before checking collision. Eg. Team 1 on collision with Team 2

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Well, your only other choice is to use "overlapping" with and "trigger once"

  • Overlapping is also checking the overlap within same team

  • I'm not sure if we are understanding each other. I thought you said on collision works but reduces performance of your game?

    "overlap" + "trigger once" is the same as "on collision".

    Well, now that I think about it, the checking of team might not work because it's the same object.

    Using collision or overlap is not your problem. The issue is how to differentiate/determine the team values.

    Can't you try using an additional variable?

    Add another var called TeamDetector

    like all objects that are Team 1 will have TeamDetector values of 1-20

    all objects that are Team 2 will have TeamDetector values of 21-40

    and so on

    If that doesn't work, and you already have them in layout at start (you don't create/spawn them at runtime), check and use all their UID or IID to differentiate them from each other.

    I'm just posting from what I think, never tried it myself.

  • ya, i used For Each loop to do the same thing. But the memory went out, because i manually check them 1 by 1 just like u said. It is nice if C2 can offer a new collision check feature.

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