Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

What should I use for this?

Asked by 9 years ago

I'm trying to create an NPC that shoots at other NPC's but I haven't found a way to actually find the other NPC's. I thought of using a Module Script to find the NPC's that were out and see if their position was close enough to the starting one, but it seems I can only use it once. I'm new to LUA and I'm unsure what I should use for this? I don't want the full out script, just what action/event I can use to call to find the nearest NPC. In advance, thanks for any help.

1 answer

Log in to vote
0
Answered by 9 years ago

Well, it seems that you are asking for a nearest distance method. If that is the case, what you should do is:

Calculate distance between them by using

(searcherNPC.Torso.Position - otherNPC.Torso.Position).magnitude

I hope this helped.

Ad

Answer this question