Is there a way to visually display line of sight?

Discussion and feedback on Construct 2

Post » Sat Feb 06, 2016 4:39 pm

Like a beam that adjusts it self if something is put between the beam emitter and its target.
B
33
S
10
G
6
Posts: 259
Reputation: 6,801

Post » Sat Feb 06, 2016 4:49 pm

Just stretch a sprite.
set width to distance(x1,y1,x2,y2)
Sprite set angle to angle(x1,y1,x2,y2)
Image ImageImage
B
170
S
50
G
178
Posts: 8,378
Reputation: 112,925

Post » Sat Feb 06, 2016 7:45 pm

This is a rough hack on top of my old CustomLOS example, but here is a Visible Beam that runs fairly quick :) https://dl.dropboxusercontent.com/u/471 ... eBeam.capx

The red LOSCheck object is much wider than the visible beam, so maybe decrease the height of the LOSCheck for the visible beam to look more accurate!

For more optimizing you could also do this:

Instead of checking every X milliseconds maybe do a function or sub-event that runs when the map has changed/moved that has each BadGuy object spawn a single check bullet.

However, the spawning of more bullets does help though if you want to increase the speed bullets travel at, since sometimes they will miss a collision in their movement. Increasing bullet size helps combat the missed collisions. I don't remember but I thought the C2 Rain demo had a laser that simulates instant-hit as well, or maybe I'm again remembering a CC example.
Last edited by Jayjay on Sat Feb 06, 2016 7:57 pm, edited 1 time in total.
"Construct 4 lets YOU make advanced games! (but not play them)" Construct Classic - Examples Kit Dropbox is a pile of trash and if you need my old files PM me! :)
B
124
S
42
G
17
Posts: 2,225
Reputation: 19,887

Post » Sat Feb 06, 2016 7:57 pm

Thanks guys, was sketching on a game where something like this would be nice. Will make sure to try you suggestions when I start building it.
B
33
S
10
G
6
Posts: 259
Reputation: 6,801


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 3 guests