The Daily Click ::. Forums ::. Klik Coding Help ::. team vs team ai
 

Post Reply  Post Oekaki 
 

Posted By Message

Zi-Xiao



Registered
  29/07/2002
Points
  537

VIP Member
23rd September, 2010 at 23:28:14 -

I'm trying to set up a system where I can have 'teams' of objects that targets the nearest object from another team. I've got some ideas on how this may be done but none of them are very simple .

The problem is basically two-fold
1) Identify nearest target
2) Lock onto the target until some sort of action (like an attack) is complete and then find another target

I'm working on something of a shooter so precision isn't NEARLY as important as simplicity and speed.

Thanks guys

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
24th September, 2010 at 17:41:59 -

Basically, I think you need to run two fastloops - one inside the other.
The first loop selects each "chaser" object, one at a time. The second loop then selects each "target" object, also one at a time, calculates the distance to the selected "chaser", and then compares this to the distance to the previous closest "target".

eg.
http://cid-b1e7ee094271bbda.office.live.com/self.aspx/Public/Seeker.mfa
http://www.create-games.com/download.asp?id=8261 (one of the examples is multiple turrets aiming at multiple targets).

You should also look into the "ForEach" extension. I haven't tried it myself, but I've heard it may be more efficient for this kind of thing.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click