Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Collision: Too Many Entities with Many Areas
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#1
Collision: Too Many Entities with Many Areas

Hi;
I have 100 entities and 20 areas. I need every single entity to collide with these 20 areas. So, would something like that work?

AddEntityCollideCallback("Entity_*", "Area_*", "Collision", false, 1);

or do I have to add these collisions one by one?

10-03-2011, 01:07 PM
Website Find
Apfel Offline
Junior Member

Posts: 19
Threads: 3
Joined: Jun 2011
Reputation: 1
#2
RE: Collision: Too Many Entities with Many Areas

(10-03-2011, 01:07 PM)Tanshaydar Wrote: Hi;
I have 100 entities and 20 areas. I need every single entity to collide with these 20 areas. So, would something like that work?

AddEntityCollideCallback("Entity_*", "Area_*", "Collision", false, 1);

or do I have to add these collisions one by one?
I'm not sure about how asterix work, but I would do it like this:

for(int i=1; i<=100; i++) {
for(int j=1; j<=20; j++) {
AddEntityCollideCallback("Entity_"+i, "Area_"+j, "Collision", false, 1);
}}


10-03-2011, 01:20 PM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#3
RE: Collision: Too Many Entities with Many Areas

I know but I really don't wanna go like that, I'm not sure how it'd affect the game performance.

10-03-2011, 01:30 PM
Website Find
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#4
RE: Collision: Too Many Entities with Many Areas

Asterix only works for the first parameter (asParent).
10-03-2011, 01:31 PM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#5
RE: Collision: Too Many Entities with Many Areas

So, over one hundred of entities could be used with just one asterix, and placing areas one by one will do the trick?
Gonna try right over.

10-03-2011, 01:43 PM
Website Find
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#6
RE: Collision: Too Many Entities with Many Areas

(10-03-2011, 01:43 PM)Tanshaydar Wrote: So, over one hundred of entities could be used with just one asterix, and placing areas one by one will do the trick?
Gonna try right over.
You could use a for loop (which was suggested above) for the second set of 20 entities - for loops aren't that slow - if the names don't just differ by numbers, you could store the names in an array and add all the entities but at that point you might just as well just copy-paste out the 20 lines.
(This post was last modified: 10-03-2011, 01:47 PM by Apjjm.)
10-03-2011, 01:45 PM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#7
RE: Collision: Too Many Entities with Many Areas

It was not a matter of loop or something. I was afraid of creating over 2000 collide calbacks and the effects of it. One of my levels already suffers from performance issues, I really don't want to create more.

Edit:
It astonishingly works without causing any performance issues and I think I got me very enjoyable puzzle/platformer Smile

(This post was last modified: 10-03-2011, 02:03 PM by Tanshaydar.)
10-03-2011, 01:50 PM
Website Find




Users browsing this thread: 2 Guest(s)