Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do spawning algorithms work in games like phantom forces and how could a person make one?

And how could I make spawning random on the map without any spawn location parts? (not requesting anything just teach me stuff if you can)

1 answer

✓ Accepted answer

You start by disabling character autoloads. https://developer.roblox.com/en-us/api-reference/property/Players/CharacterAutoLoads

Next you can use the player:LoadCharacter() method to load the characters you want or need (although phantom forces uses a pseudo character iirc. https://developer.roblox.com/en-us/api-reference/function/Player/LoadCharacter

Finally you can determine random spawn locations using math.random and vector3.new https://developer.roblox.com/en-us/api-reference/lua-docs/math

https://developer.roblox.com/en-us/api-reference/datatype/Vector3

If you want truly dynamic and random spawning you can also use some trickery with multiple spawn zones determined by multiple uses of math.random. Further if you only use math.random for the x and z component you can potentially use raycast from some high altitude to find the ground position (for assuming an uneven surface) so you don't spawn people in the sky.

1 comment

0

I think he also meant spawning far away from enemies

This discussion is preserved as it was. New answers, comments, and votes are closed.