# Distance vs Collision - For Each Object...

Discussion and feedback on Construct 2

### » Wed Feb 27, 2013 4:38 am

Hi pals, i'm not sure if this a bug or design, i'm trying to make the game without collision because C2 has great collision managment but it can cause performance issues for mobiles, compared to other HTML5 games don' use specificed collison may save good FPS for mobiles.

I've seen C2 blog talked about FPS comparison for mobiles, they showed between 2X to 57 fps, but i'm getting 60 fps without complex collision system.

At this moment, i'm having a problem, it breaks trigger once for each more than 2 objects in targeted distance.

It uses loop for each.

Reproduce to problem
1-Wait to get hit by one, it only substracts by 10
2-While get hit by 2 bullets, it breaks trigger once and substract 10 in every tick.

Demo:
http://flamma-beta.com/HTML5/TriggerOnceForEach/

.capx:
http://dl.dropbox.com/u/76227787/TriggerForEachIssue.capx

B
104
S
29
G
22
Posts: 3,066
Reputation: 24,273

### » Wed Feb 27, 2013 11:15 am

I havent used "Trigger Once".. but perhaps it should not be a "sub event", and should be the last condition of the event its supposed to operate on?..

you could always used squared_dist as opposed to distance.. its a little faster..

x3 = (x2-x1)
y3 = (y2-y1)

squared_dist = (x3 * x3) + (y3 * y3)

use "abs(squared_dist)" if you dont negatives..

if (abs(squared_dist) <= collision_rad_squared) collision = true

Hope that helps.. :)matt752013-02-27 11:17:21
B
6
G
2
Posts: 37
Reputation: 1,499

### » Wed Feb 27, 2013 10:45 pm

@matt75

I'm sorry for ignorance,

How do you apply if (abs(squared_dist) <= collision_rad_squared) ) in C2 events?
B
104
S
29
G
22
Posts: 3,066
Reputation: 24,273