How do I draw the line of sight behaviour cone?

Get help using Construct 2

Post » Sun Apr 20, 2014 11:01 pm

So I have a game that uses turrets, and I want to use the line of sight object to detect players, and show the line of sight cone for the player to see. However I also want it to occlude to the walls like below:

Image

This one was done by blending a light cone graphic with a canvas with rendered "shadows", which is very effective but very costly, especially if you are using multiple turrets.

Any ideas for a more simpler method? Probably one that actually uses the line of sight behaviour?
B
24
S
5
G
1
Posts: 89
Reputation: 3,015

Post » Mon Apr 21, 2014 3:29 pm

This could be very tricky to do.

Programming-wise, what I would do is to check for any "obstacle" insight with quad tree data structure and draw my fan polygon's points with respect to all these obstacles. This one single sentence requires a hair or two to fall off from your head while implementing.

But in C2, this could be tough unless you can find a plugin that can address the above.

Instead of a cone, what about a laser sight that quickly move back and forth like those retina scanner in movies instead? If done right, it could achieve similar effect like the cone with better performance. But this will still require trigonometry work to address the walls, etc in your event sheets. ...good luck.
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,469

Post » Mon Apr 21, 2014 9:35 pm

That radar line idea sounded quite cool, so I thought I'd implement it and performance is incredible. The vision cone implementation I explained earlier used around 5% of the CPU on my desktop, which isn't much except that the radar method only uses less than 1%!

See for yourself!

Athough I'm thinking of if there is any way to improve the visibility of it, I was thinking of making it trail but that would add to drawing. :/
B
24
S
5
G
1
Posts: 89
Reputation: 3,015

Post » Mon Apr 21, 2014 10:17 pm

Although I am already amazed from both results (I can't begin to understand what are you two saying above), the example with the line is a bit misleading imho. If I saw that in a game, I would assumed that the line of sight is pinpointed and rotates back and forward, not that it actually covers the whole area of the cone.

This 3 part series of tutorials has some interesting ideas that perhaps could prove of some value to your work

https://www.scirra.com/tutorials/792/the-land-of-light-and-shadows-part-1
https://www.scirra.com/tutorials/793/the-land-of-light-and-shadows-part-2
https://www.scirra.com/tutorials/796/the-land-of-light-and-shadows-part-3
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Tue Apr 22, 2014 1:03 am

@gamepopper nice result you got there, man. But what I would do is to make those laser move quicker to imply its importance visually. But up to you though.

I got 60 fps on my smartphone here.
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,469

Post » Tue Apr 22, 2014 8:18 am

@keroberos Yeah, the example uses a sine wave at 2 second periods, just to show that it works.

@eli0s I can see your point. I think it might work better if there was a trail effect or have more than one line displaying at a time. Just need to experiment with it.
B
24
S
5
G
1
Posts: 89
Reputation: 3,015

Post » Tue Apr 22, 2014 1:53 pm

Perhaps you can spawn a number of lines within the tower view cone, or randomly change the laser angle to fill the line of sight area.

The canvas plugin can do trail effects, although it's a bit strange in its usage, I can't figure out why a small trail is being left visible in the following example.

Example capx: http://www.eli0s.com/Tests/TowerLaser.capx (the 3 left towers aim at the mouse position)

Canvas Plugin: https://www.scirra.com/forum/plugin-canvas_t64239
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Tue Apr 22, 2014 6:57 pm

How does this look:

Image
B
24
S
5
G
1
Posts: 89
Reputation: 3,015

Post » Tue Apr 22, 2014 7:13 pm

Thats looking preety cool so far. I wonder if you could change the color when you detect your "target"... it would give you a nice dramatic effect.
Freefall Bird
B
47
S
9
G
5
Posts: 280
Reputation: 5,796

Post » Tue Apr 22, 2014 7:27 pm

That's great gamepopper, great gob. The color change if on sight that Ragevortex suggests will be awesome too ;)
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 40 guests