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
28
S
10
G
6
Posts: 251
Reputation: 6,655

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
164
S
49
G
138
Posts: 7,957
Reputation: 91,880

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
B
102
S
35
G
17
Posts: 2,158
Reputation: 18,481

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
28
S
10
G
6
Posts: 251
Reputation: 6,655


Return to Construct 2 General

Who is online

Users browsing this forum: lasneo and 6 guests