[quote:yh0c4699]What i would normally do is, make an event 'when ball is in collision with obj1-turn ball blue'. Now what if added another condition of 'ball is within x' , where the object lies within the x limit. Will this help on improving performance?. instead of checking for collisions every tick for every ball-object comb, it would only check if ball is within the object's x range. Does it work that way?, or have i mistaken it?
There are some things you can do to improve performance. First of all never use "On collision", which sounds a bit weird when that is what you want to do . However that event for some reason is very demanding and if you need to do a lot of collision detection that will kill performance quite fast. Instead use "Is overlapping".
Also your idea of only check for collision based on range seems to be the most effective way of improving performance, This is from a test I did some time ago:
[quote:yh0c4699]
(Collision group is the name of the group in my program that does the distance checking, not something you find in C2)
1. Using overlapping (With the Collision group disabled)
Number of objects: 2490
FPS: 8-9
Collision checks per sec: 18000-21000
2. Using On collision event (With the Collision group disabled)
Number of objects: 2512
FPS: 2-3
Collision checks per sec: 1013025+
3. Using overlapping (With the Collision group Enabled)
Number of objects: 2501
FPS: 29-30
Collision checks per sec: 12000-15000
4. Using On collision event (With the Collision group enabled)
Number of objects: 2464
FPS: 3-4
Collision checks per sec: 2048000-3100000
These are my tests that I just did, as it removes overlapping objects before checking collisions, there is a slight difference in amount of objects. But nothing that will change the results in any significant way.
But if you look at the collision per secs, which is from the debugger, it goes nuts on the On collision event, even when you remove the squares that are overlapping. So something is clearly not the same but there aint really a lot you can do with the "On collision" event as its part of C2 and cant be modified.
Number 3 uses a functionality that disable collision checking based on range. So adding something like this can increase performance quite a lot.