The Daily Click ::. Forums ::. Klik Coding Help ::. ranged detector
 

Post Reply  Post Oekaki 
 

Posted By Message

Don Luciano

Heavy combat pancake

Registered
  25/10/2006
Points
  380

VIP Member
29th September, 2008 at 14:27:31 -

What is the best way to set up range detection. The closest unit.

I have bout 20 unist on one side, 20 on other. I need to detect the closest, for each 20.

 
Code me a sausage!

Klikmaster

Master of all things Klik

Registered
  08/07/2002
Points
  2599

Has Donated, Thank You!You've Been Circy'd!VIP MemberPS3 Owner
29th September, 2008 at 15:36:08 -

Your best bet would probably be to run a fastloop through your units and store the distance into one of their alterable values. As you are going through the loop, store the id of the unit and it's distance if it the distance value is lower than the one from the previous loop.

Make any sense?

 
n/a

Don Luciano

Heavy combat pancake

Registered
  25/10/2006
Points
  380

VIP Member
29th September, 2008 at 16:27:42 -

yes, but how would i check the distance? I know 360 extension but it needs a lot of events to work properly.
What's my best option?
And i think that going throught each of enemies, check, for each unit on my side, could be quite laggy.
I know that 360 has find fixed of closest. But that doesn't work very well often.

Image Edited by the Author.

Umm nevermind solved it. But thx anyway.

Image Edited by the Author.

 
Code me a sausage!

traugott.simon



Registered
  23/08/2008
Points
  91
1st October, 2008 at 08:22:33 -

Sqr((X( "Player" )-X( "Enemy" ))*(X( "Player" )-X( "Enemy" ))+(Y( "Player" )-Y( "Enemy" ))*(Y( "Player" )-Y( "Enemy" )))


That should work Put that in a value
Its always a good idea to test such explanations in a seperate frame an display the value with a counter to see how it works.

Image Edited by the Author.


EDIT: i didnt recognized that you have already solved the problem. Anyway mayby its interessting for others

Image Edited by the Author.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click