Lumina Posted July 15, 2017 Share Posted July 15, 2017 (edited) Hi, I have a working code doing what i want, except one point : it is supposed to spawn a prefab somewhere in the world, and this part works, but the prefab could spawn in tiles players aren't supposed to reach. Here is the code : local pt = Vector3(math.random(-1000, 1000), 0, math.random(-1000, 1000)) local tile = TheWorld.Map:GetTileAtPoint(pt.x, pt.y, pt.z) local myprefab = SpawnPrefab("myprefab") myprefab.Transform:SetPosition(pt:Get()) print("Prefab spawned") Usually i use a variant of this code : local pt = Vector3(math.random(-1000, 1000), 0, math.random(-1000, 1000)) local tile = TheWorld.Map:GetTileAtPoint(pt.x, pt.y, pt.z) if tile == GROUND.DECIDUOUS then local myprefab = SpawnPrefab("myprefab") myprefab.Transform:SetPosition(pt:Get()) print("Prefab spawned") end But in this case i don't want to spawn it on a specific ground, only on "valid" ground (don't care which one) What is the best way to do it ? Edit : maybe found something with "~= GROUND.IMPASSABLE", will do some tests. Edited July 15, 2017 by Lumina Link to comment Share on other sites More sharing options...
ZupaleX Posted July 15, 2017 Share Posted July 15, 2017 You answered your question. GROUND.IMPASSABLE contains the tiles where player characters cannot walk (ocean/sea tiles, black pit in the caves, ...) Link to comment Share on other sites More sharing options...
Lumina Posted July 15, 2017 Author Share Posted July 15, 2017 perfect, thanks I also found a "GROUND.INVALID", i guess it will do no harm to avoid it too. Link to comment Share on other sites More sharing options...
ZupaleX Posted July 15, 2017 Share Posted July 15, 2017 (edited) Probably, I don't remember exactly all the GROUND table's member. You have the complete list in constants.lua You probably want to avoid GROUND.FAKE_GROUND also, whatever it is (it did not exist last time I was modding) Edited July 15, 2017 by ZupaleX Link to comment Share on other sites More sharing options...
Lumina Posted July 15, 2017 Author Share Posted July 15, 2017 I'll see this, thanks for the advice Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now