1
\$\begingroup\$

I'm making an enemy object where the enemy look for the player when he's going on a patrol

I want the vision cone to changes direction corresponding to the sprite.When the sprite turn right,the cone will faces right,left and the cone will faces left and when he move to any direction the cone will move with him and changes direction accordingly

I also want to give the cone certain ranges.The longest range's where the enemy will be in doubt and get to that position to investigate,medium range he'll start chasing,shortest range he'll attack.

I hope someone can help me.

\$\endgroup\$
0
\$\begingroup\$

enemy line of sight has some standards that works in all engines and languages. i show you the algorithm,you can implement this on your game maker engine:

if (target overlapping sphere)// if its near than a value to me
{

    direction = Normalize(target - this);//target is enemy position. this is my position
    dot = Dot(direction, forward);// it means dot product. you can calculate it yourself or find library to do this for you
    if (dot > 0.707)// you can change this for bigger or less eye sight
    {
     //  I see target!
    }
}
\$\endgroup\$
  • \$\begingroup\$ Thanks for the help.My vision cone doesn't so good but i'll manage.I also want to know sprite based direction,for example if my sprite index is 'Right' the cone'll turn right and so on.Any suggestions ? \$\endgroup\$ – TankRocket Oct 27 at 0:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.