On Collision Problem

Get help using Construct 2

Post » Fri Jan 02, 2015 5:16 pm

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:
problem.png

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.
You do not have the required permissions to view the files attached to this post.
Last edited by StormHo on Sat Jan 03, 2015 2:57 pm, edited 2 times in total.
B
17
S
4
G
1
Posts: 203
Reputation: 1,583

Post » Fri Jan 02, 2015 10:42 pm

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
ImageImage
B
114
S
51
G
24
Posts: 790
Reputation: 23,480

Post » Sat Jan 03, 2015 10:44 am

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
B
17
S
4
G
1
Posts: 203
Reputation: 1,583

Post » Sat Jan 03, 2015 1:55 pm

Well, your only other choice is to use "overlapping" with and "trigger once"
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Sat Jan 03, 2015 2:19 pm

Overlapping is also checking the overlap within same team
B
17
S
4
G
1
Posts: 203
Reputation: 1,583

Post » Sat Jan 03, 2015 3:41 pm

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.
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Sat Jan 03, 2015 4:03 pm

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.
B
17
S
4
G
1
Posts: 203
Reputation: 1,583


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests