The Daily Click ::. Forums ::. Klik Coding Help ::. Halp needed

Post Reply  Post Oekaki 

Posted By Message

Digital Guy

  12/06/2018 08:25:21
12th June, 2018 at 12/06/2018 08:45:40 -

I'm having trouble finding a way to make a line of sight ai, and cant find any tutorials to help me, can someone help me or send me on the right way?

The best of the worst




Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
12th June, 2018 at 12/06/2018 15:58:47 -

Well consider an AI that has two states:

-Don't see you
-See you

When they see you they can just move towards you and shoot or something, and when they don't they can just move around randomly and scan for you.

Now for the fun part. How do you determine when they should change states?

Well one way would be to have them shoot and invisible detector towards to the player on an interval (every 10 seconds or so) and then when a detector hits a wall you destroy them, but when it hits the player have the enemy switch to the "See you" state.

When the detector touches the player you can either have all the enemies see you, or just the ones closest to you. You can use a foreach loop to accomplish this along with the distance formula.

Good luck!


Post Reply



Worth A Click