Jump to content


Photo

Giving A.i. 180 Degree Sight Than Can Be Also...


  • This topic is locked This topic is locked
4 replies to this topic

#1 J-Labs

J-Labs

    J-Labs

  • New Member
  • 339 posts

Posted 07 July 2006 - 11:42 PM

This is for a Top down shooter

Ok well since the enemy is roatating and changing direction i need it to to always just check to see if the player is in the 180 degree view in front of him. But the catch is that even if he is in this 180 degree view i need itto check if there is a wall between them and if there is then the player is not visible.

I'm not that great with math and certain types of fuctions so i couldnt figure this one out myself.

well please tell me if you need a better description or anything else

Edited by J-Labs, 08 July 2006 - 01:43 AM.

  • 0

#2 xot

xot

    media multimixer

  • Global Moderators
  • 4653 posts
  • Version:GM:Studio

Posted 08 July 2006 - 12:01 AM

Read this topic:
http://forums.gamema...howtopic=118478
  • 0

#3 Dragen

Dragen

    GMC Member

  • New Member
  • 299 posts

Posted 08 July 2006 - 12:01 AM

well what i would do is make a sprite that is half a circle, as large as you want his view to be, then make the origin at the bottom middle, and make it facing all the ways as the guy (36 frames or whatever you used). then put in the same coding and stuf for it as the guy and put it over him, make it so it jumps to him, and make collision with obj_character (or whatever you named it), then make the enemy and the sight move to your character, or make it do what you want it to. make sure it is always following the character, then uncheck the visiblility box. im not very good at desribing stuff.... i hope you understand what i meant.
  • 0

#4 kaz3

kaz3

    GMC Member

  • New Member
  • 730 posts

Posted 08 July 2006 - 01:14 AM

I would use multiple collision lines in a for loop.

for(i=-90;i<90;i+=10){//checks from - 90 to 90, 180 degrees
if collision_line(x,y,x+lengthdir_x(distance,directio
n+i),y+lengthdir_y(distance,direction+i),obj,0,1){
//some code
}
}
  • 0

#5 J-Labs

J-Labs

    J-Labs

  • New Member
  • 339 posts

Posted 08 July 2006 - 01:43 AM

Ok thanks for you help Kaz3

And thanks to xot to since i was looking for that topic
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users