[C2]Enemy: Line of Sight

Show us your completed creations made in Construct 2

Post » Fri Oct 07, 2011 9:52 pm

Hey, Dcrew here!

Just wanted to show off a creation here. (PM me if you wonder how it's done)



The line is always between the Player and Enemy (can have as many enemies as you want) and set's the line's width to the distance between the Player and Enemy and set's the angle towards the Player and it's position at the Enemy.

When the Line touches obstacles or walls or (anything you want really) it turns Red. thus meaning it cannot see you! But when it's green it can see you, thus making it aim at you and see-ing you!

I think this is a really good idea for enemy AI in games and will go great with Pathfinding :D

Thanks!

Click here to Download the Source file (Main)

Click here to Download the Source file (Mirror)Kyatric2011-10-08 01:41:42
B
17
S
4
G
5
Posts: 226
Reputation: 4,042

Post » Fri Oct 07, 2011 10:20 pm

You should post the cap and/or exe.

Edit: I edited the topic name to state it is for C2.Kyatric2011-10-08 01:42:14
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Fri Oct 07, 2011 10:45 pm

[QUOTE=Kyatric] You should post the cap and/or exe.[/QUOTE]

Updated first post with download links!
B
17
S
4
G
5
Posts: 226
Reputation: 4,042

Post » Sun Nov 06, 2011 12:21 am

This is great, and would probably work with platform type environment with a little tweak... would it be simple to add restrictions to the angle the line is able to move? ie... restrict the enemy's field of view?

I'll try fiddling to see what can be done.
B
28
S
7
G
7
Posts: 102
Reputation: 6,483

Post » Sun Nov 06, 2011 12:34 am

@plauk, it would probably be easier to add conditions to when you are seen rather than restrict the line's movement. I'm using a similar system for my game, and though I'm not up to that part yet, I've given it a lot of thought and that seems to be the way to go.
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Sun Nov 06, 2011 11:31 pm

@plauk It would be super easy to do that. Just make it so the line will only go green (it can only spot player) if the distance between the two are below 400 (or w/e you want)
B
17
S
4
G
5
Posts: 226
Reputation: 4,042

Post » Mon Mar 26, 2012 7:52 pm

Your the man ^_^
B
9
S
4
G
3
Posts: 223
Reputation: 3,433

Post » Mon Aug 20, 2012 4:55 am

wow very nice, i need this solution for my game. Thank yuo
B
18
S
3
Posts: 5
Reputation: 1,426

Post » Fri Nov 16, 2012 2:16 am

@dcrew ..thanks for this man.

Improved parts of it and added range calculations and stuff.
Hope it helps someone looking for such

Tutorials - enemy-ai-for-range-of-fire-and-line-of-sight-top-down-playerkrish2012-12-10 13:28:02
Krish
Hey! Did you know that you can hire me to make your games?

Click Here to See More
B
21
S
6
G
5
Posts: 391
Reputation: 5,627

Post » Mon Dec 03, 2012 5:56 pm

Thank you my friend.
B
17
S
4
G
5
Posts: 226
Reputation: 4,042

Next

Return to Completed Creations

Who is online

Users browsing this forum: No registered users and 5 guests