The Daily Click ::. Forums ::. Klik Coding Help ::. Distance detection
 

Post Reply  Post Oekaki 
 

Posted By Message

hapsi



Registered
  13/11/2003
Points
  775
21st August, 2010 at 21:46:46 -

Allright.. i have problem with my npc characters sight detection. The engine works like this:
Player is less than 300 pixels from enemy --> Enemy starts to shoot sight detection objects.

Actual events:
Compare two general values: Sqr( ( X( "player hitbox" ) - X( "NPC Enemy hitbox" ) ) pow 2 + ( Y( "player hitbox" ) - Y( "NPC Enemy hitbox" ) ) pow 2 ) IS LESS THAN 300 ---> [Enemy]=Shoot "enemy sight object"

Image

Now the enemy shoots sight objects but if there are several enemies, the enemy start to shoot "enemy sight objects" only when im close to one specific enemy. If im close to another enemy (identical active object) it wont.


Taking out sFH 18 artillery squad
Image

 
[Signature][/Signature]

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1968

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
21st August, 2010 at 22:22:13 -

You can't use "compare two general values" with multiple instances.
You need to use an alterable value, and say something like:

+ Always
-> NPC: Set "Range" to Sqr( ( X( "player hitbox" ) - X( "NPC Enemy hitbox" ) ) pow 2 + ( Y( "player hitbox" ) - Y( "NPC Enemy hitbox" ) ) pow 2 )

+ "Range" of NPC < 300
-> NPC: Shoot enemy sight object


 
n/a

hapsi



Registered
  13/11/2003
Points
  775
22nd August, 2010 at 00:33:34 -

Ah, thats it. Thank you!

 
[Signature][/Signature]
   

Post Reply



 



Advertisement

Worth A Click