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

CaveCricket48

Joined: Tue Jun 12, 2007 11:52 pmPosts: 10625Location: Here

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.

Who is online

Users browsing this forum: No registered users

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