#Selecting Multiple Targets in cone

36 messages · Page 1 of 1 (latest)

calm kettle
errant fable
#

Basically you'll have to rewrite the script so that your NPC checks each render stepped for the people in the range, and not a script for each player that joined

calm kettle
errant fable
#

Well

#

It depends what you want

calm kettle
#

Here is the example of reworked code

#

Is it ok?

errant fable
#

You should organise your code in several functions

calm kettle
#

I'm trying to check every time when my tower attack if mobs are inside my cone aoe

errant fable
#

Wait

#

So what you want is to have a tower that attacks mob in their cone ?

calm kettle
#

yes

errant fable
#

Like a tower defense game ?

calm kettle
#

Yes, it is

errant fable
#

Well you can calculate locally for each tower who is in their range and shot them

#

But that will cost a lot of server resources

#

So basically if someone puts 1000 turrets in their game that may cause server lags

calm kettle
#

So, then my method is not so good?

mental bearBOT
#

studio** You are now Level 1! **studio

errant fable
calm kettle
#

I need just to check which mobs are inside my cone when my tower attack

errant fable
#

Alr

#

I read your code

#

And it is great but you're overcomplicating things

calm kettle
#

Very probably

errant fable
#

I think you don't need the mob inside variable since looping through children won't pass twice on a mob

calm kettle
#

oh, my bad xD

errant fable
#

You can however do a capping for mobs with like a number that decrease that is the max mobs a tower can damage

calm kettle
#

I forgot that I receive the models

errant fable
#

But yea basically you can just do

for _, mob in next, mobFolder:GetChildren() do
  tower:damageMob(mob)
end
#

And you can use Oop for your towers if they have different properties and stuff

#

It would make your life easier