View unanswered posts | View active topics It is currently Tue Mar 19, 2024 5:11 am



Reply to topic  [ 3 posts ] 
 Number of actors in a radius 
Author Message
User avatar

Joined: Sat Nov 10, 2012 3:31 pm
Posts: 114
Location: Australia
Reply with quote
Post Number of actors in a radius
How would I go about detecting the number of specific actors in a certain distance from the actor calling the script, then write it to a variable?
For example;

Check for the amount of coalition light's that are within a radius of 100 pixels, if they're on my team then set the variable self.Noomboomba to that amount.


Thu Dec 08, 2016 7:19 am
Profile WWW
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post Re: Number of actors in a radius
Something like

Code:
function Update(self)
  self.Noomboomba = 0;

  for actor in MovableMan.Actors do
    if actor.PresetName == "Coalition Light" and SceneMan:ShortestDistance(self.Pos, actor.Pos, SceneMan.SceneWrapsX).Magnitude < 100 then
      self.Noomboomba = self.Noomboomba + 1;
    end
  end

end


After the 'for actor' block, self.Noomboomba will have the number of Coalition Light units in range, or whatever they're named.


Thu Dec 08, 2016 2:40 pm
Profile
User avatar

Joined: Sat Nov 10, 2012 3:31 pm
Posts: 114
Location: Australia
Reply with quote
Post Re: Number of actors in a radius
That was exactly what I was looking for. Many thanks.


Thu Dec 08, 2016 4:38 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.398s | 17 Queries | GZIP : Off ]