Distance(x1, y1, x2, y2) vs Collision with hidden object.

Discussion and feedback on Construct 2

Post » Sat Dec 10, 2016 12:00 am

Which one is more labor intensive for Construct 2?
Physics are not being used.

If Distance is less intensive for the system you could prevent the need of using collision detection.
I'm not sure how Collisions are handled.


Distance(x1, y1, x2, y2) seems more beneficial because it is easier to work with, and is seemingly only 1 mathematical calculation.

Collision seems like it would be the same or similar calculation, plus it would have to render hidden objects and resize/destroy/create them as needed.

I read a few times that collisions can take up a lot of resources.

Just curious on which one would be easier for devices.
B
62
S
35
G
13
Posts: 230
Reputation: 12,402

Post » Sat Dec 10, 2016 12:24 am

I prefer collision detection/overlap. Burt only when used as first conditon in a top level event.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sat Dec 10, 2016 1:21 am

The way it is structured is important. It should almost always be the top level event.

It just seems like Distance would be easier for most cases and would be easier on the system.
B
62
S
35
G
13
Posts: 230
Reputation: 12,402

Post » Sat Dec 10, 2016 2:32 am

It would depend on the shape of the collision area.
Also you would have to create a picking mechanic for multiple instances as distance won't do that for you.
That means it will probably be slower.

Or you could just use line of sight.
Image ImageImage
B
169
S
50
G
169
Posts: 8,286
Reputation: 108,216

Post » Sat Dec 10, 2016 3:04 am

Collision would probably be better for random uncontrollable cases. I suppose if the situation is specific then it would be better to use Distance.

How would I use Line of Sight? That is only to see if an object can be 'seen'.
B
62
S
35
G
13
Posts: 230
Reputation: 12,402

Post » Sat Dec 10, 2016 3:48 am

It has a range.
Image ImageImage
B
169
S
50
G
169
Posts: 8,286
Reputation: 108,216

Post » Sat Dec 10, 2016 5:48 am

I think "distance" uses the Pythagorean Theorem, so there would be squaring and square roots involved. I'm not 100% certain, but I think it would be lighter computation to do compare X and compare Y. That would allow for collisions between rectangular objects, whereas distance would treat everything as a circle.
Eh, Steve!
B
114
S
54
G
13
Posts: 112
Reputation: 16,120

Post » Sat Dec 10, 2016 7:08 am

I'm not 100% sure what you mean by compare X and compare Y?
I think I would have to compare X and Y on all sides of the object that way.
B
62
S
35
G
13
Posts: 230
Reputation: 12,402

Post » Sat Dec 10, 2016 10:31 am

B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sat Dec 10, 2016 5:34 pm

Useful link. :geek:

Knowing how Collision cells work is good.
B
62
S
35
G
13
Posts: 230
Reputation: 12,402

Next

Return to Construct 2 General

Who is online

Users browsing this forum: lukewasthefish, thimas and 8 guests