Frictional Games Forum (read-only)

Full Version: Collision: Too Many Entities with Many Areas
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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)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);
}}


I know but I really don't wanna go like that, I'm not sure how it'd affect the game performance.
Asterix only works for the first parameter (asParent).
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)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.
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