Line of sight between bounding boxes

Discussion and feedback on Construct 2

Post » Fri Jan 22, 2016 2:49 pm

Line of sight checks if objects can see each other by checking is it possible to draw line between origins of those objects. But is it possible to check line of sight between bounding boxes of compared objects?
This would be useful for big objects.
B
55
S
14
G
10
Posts: 287
Reputation: 7,677

Post » Tue Jan 26, 2016 11:04 am

Does anybody have idea?
B
55
S
14
G
10
Posts: 287
Reputation: 7,677

Post » Tue Jan 26, 2016 4:24 pm

You could use proxy objects to detect other parts of your big character. See the following capx (it's very messy code-wise, but you should get the idea).

https://www.dropbox.com/s/if0hvfv8jg2rndz/LoS.capx?dl=0

What I would very much like to see ( @Ashley ) is a visual LoS cone, either for gameplay purposes or just for debugging.
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Tue Jan 26, 2016 5:45 pm

This is a trickier problem than you think: if it worked as you described based on both sides being able to see the complete object, then all it would take is a single pixel corner of an object poking in to the LOS region to count as not visible. So then you really want to define something like the percentage of the object that is visible... but then calculating that with a few small objects strewn around the area between the two objects becomes extremely difficult.

As @eli0s suggests the simplest way to fake this is to allow LOS to multiple positions around an object, using extra sprites.
Scirra Founder
B
399
S
236
G
89
Posts: 24,543
Reputation: 195,430

Post » Fri Jan 29, 2016 11:34 am

@Ashley , any chance to add a "visual cone of view" to the Line of Sight behavior..? Something like this..?

Making this with the Shadow&light object is too bothersome and it doesn't work with low value angles...

Here is the capx for anyone interested for this method.
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Fri Jan 29, 2016 12:27 pm

That faces the same difficulties I described: to work well in all situations, it would need to identify a percentage view coverage.
Scirra Founder
B
399
S
236
G
89
Posts: 24,543
Reputation: 195,430

Post » Fri Jan 29, 2016 1:16 pm

@Ashley , what I ask doesn't change the way Line of Sight behavior works now, it just adds a visual representation of the cone, an approximation that could be very useful for both debugging and gameplay design-wise purposes. For a more accurate detection, we could just add proxy objects and define the boundaries however we like.
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 2 guests