Best way to spawn NPCs in random possible locations
4 replies, posted
As the title says, what's the best way to spawn NPCs in random possible locations? Avoiding them to spawn in walls.
Have a table of all the random location coordinates you want, then use math.random to select a table key.
[QUOTE=code_gs;46218003]Have a table of all the random location coordinates you want, then use math.random to select a table key.[/QUOTE]
That's not what I'm looking for though. I've tried to make an automated way to [i]do that[/i] but all I came up with was this inefficient function:
It spawns an NPC somewhere around a specified area, if the NPC is stuck, it will be immediately removed and it will try again til it spawns.
Check if the position is valid BEFORE you spawn it then.
[QUOTE=code_gs;46218065]Check if the position is valid BEFORE you spawn it then.[/QUOTE]
How? :tinfoil:
What I do is checking if it is colliding but how can I do it without spawning it?
Sorry, you need to Log In to post a reply to this thread.