[C2]Enemy: Line of Sight Forum Home > Construct 2 General > Your Creations |
Post Reply
|
Page 12> |
| Author | |
Post Options
Quote Reply
Topic: [C2]Enemy: Line of SightPosted: 07 Oct 2011 at 9:52pm |
|
|
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) Edited by Kyatric - 08 Oct 2011 at 1:41am |
|
|
bool exCeption = true;
if (exCeption()) { exCeption = false; inCeption(); } void inCeption() { if(!exCeption()) { inCeption(); } } |
|
![]() |
|
Post Options
Quote Reply
Posted: 07 Oct 2011 at 10:20pm |
|
|
You should post the cap and/or exe.
Edit: I edited the topic name to state it is for C2. Edited by Kyatric - 08 Oct 2011 at 1:42am |
|
![]() |
|
Post Options
Quote Reply
Posted: 07 Oct 2011 at 10:45pm |
|
Updated first post with download links! |
|
![]() |
|
Post Options
Quote Reply
Posted: 06 Nov 2011 at 12:21am |
|
|
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. |
|
![]() |
|
Post Options
Quote Reply
Posted: 06 Nov 2011 at 12:34am |
|
|
@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.
|
|
|
All's fair in love and war, kid.
|
|
![]() |
|
Post Options
Quote Reply
Posted: 06 Nov 2011 at 11:31pm |
|
|
@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)
|
|
![]() |
|
Post Options
Quote Reply
Posted: 26 Mar 2012 at 7:52pm |
|
|
Your the man ^_^
|
|
![]() |
|
Post Options
Quote Reply
Posted: 20 Aug 2012 at 4:55am |
|
|
wow very nice, i need this solution for my game. Thank yuo
|
|
![]() |
|
Post Options
Quote Reply
Posted: 16 Nov 2012 at 2:16am |
|
|
@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-player Edited by krish - 10 Dec 2012 at 1:28pm |
|
|
Have a Power-Up Day!
-- Krish I lives in a cave nd writes me games - "Tank 'em Up" is coming soon! I haz facebook.com/toonheart |
|
![]() |
|
Post Options
Quote Reply
Posted: 03 Dec 2012 at 5:56pm |
|
|
Thank you my friend.
|
|
|
bool exCeption = true;
if (exCeption()) { exCeption = false; inCeption(); } void inCeption() { if(!exCeption()) { inCeption(); } } |
|
![]() |
|
Post Reply
|
Page 12> |
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |