tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
|
| 20 Sep 2013 04:51 PM |
Accidentally made it not allow reposts... oops!
Okay, for the last couple of days, I've been working on an infinitely generating map... I actually made some progress, except the land only generates in 4 directions... I've tried several ways to try to make it spawn land in between... from checking if the player jumps off, making it spawn parts next to it... everything! Does anyone have any suggestions on what I can do?
The game currently works by having 4 scripts, each handling one of the direcitons... here's one of them:
limitRX = 50
while true do wait(0.1)
if game.Workspace.Player1.Torso.Position.X <= limitRX and game.Workspace.Player1.Torso.Position.Y == game.Workspace.Player1.Torso.Position.Y and game.Workspace.Player1.Torso.Position.Z == game.Workspace.Player1.Torso.Position.Z then
print 'Generating land in RX Position....'
a = game.Workspace.Chunk:clone() a.Parent = Workspace a:TranslateBy(Vector3.new(limitRX-178,y,z)) limitRX = limitRX-128 print 'Generation complete' end end
and another for a z position, just in case:
limitZ = 40
while true do wait(0.1)
if game.Workspace.Player1.Torso.Position.Z <= limitZ and game.Workspace.Player1.Torso.Position.Y == game.Workspace.Player1.Torso.Position.Y and game.Workspace.Player1.Torso.Position.X == game.Workspace.Player1.Torso.Position.X then
print 'Generating land in Z Position....'
a = game.Workspace.Chunk:clone() a.Parent = Workspace a:TranslateBy(Vector3.new(x,y,limitZ-168)) limitZ = limitZ-128 print 'Generation complete' end end
The game takes a model named chunk---A large piece of land made of about 40 bricks, each named "ChunkPart" and one named "ChunkPartS" which handles spawning things on the ground--- from the lighting and places it in front of the player when they go past the map's current limit.
Is there any way to make it spawn land in between, or should I just scrap the code and start from scratch? |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 20 Sep 2013 04:54 PM |
I'd scrap the entire code. What you should do is use a nested for loop.
for x = -500, 500, 1 do for z = -500, 500, 1 do local q = a:clone() q.Parent q.CFrame = CFrame.new(sizeOfObject*x, y, sizeOfObject*z) wait(.0001) end end
Of course, change the -500, 500 to whatever you want....
And a is the object that you're cloning... |
|
|
| Report Abuse |
|
|
tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
|
| 20 Sep 2013 05:03 PM |
K, couple of questions and problems. First, it tells me there's an error on line 5: " '=' expected near 'q' " And second what do you mean by size of object at line 5? Is this a mistake, or are you referring to the size of the cubes that make up the model? |
|
|
| Report Abuse |
|
|
tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
| |
|
tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
|
| 20 Sep 2013 05:24 PM |
| Okay, this script does something, but it has plenty of problems... when I load a model into it, it tells me that Cframe isn't a valid part of the model... when I load a part into it, it spawns an infinitely long line of bricks about 5000 studs away from the player... What's going on? |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 20 Sep 2013 05:35 PM |
| What I gave wasnt an exact script. It was just a guide on how to do it, enough info to tell you how you should do it. You cant use CFrame on a model. You need a part.... And in the case of the part, well, lets just say that maybe the script isnt finished loading XD |
|
|
| Report Abuse |
|
|
tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
|
| 20 Sep 2013 05:37 PM |
| I've been playing with it, and I'm beginning to understand... How do I tweak this to spawn more when the player reaches the end of the map? ...and is there any way to make the parts spawn simultaneously to make it faster? |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 20 Sep 2013 05:54 PM |
Well now thats getting into some rly rly advanced scripting..... Thats not going to be a "tweak", its going to overthrow the entire script...
But if you want simulatenous generation, just remove the wait(.0001), but I threw that in there to avoid risking crashing the game. Because I have a darn good feeling that it will if you remove the wait(.0001)
I guess you could try placing a script into each brick saying
function onTouched(part) if game.Players:GetPlayerFromCharacter(part.Parent) then area = game.Workspace:FindPartsInRegion3(Vector3.new(-50, -1, -50)+script.Parent.Position, Vector3.new(50, 1, 50)+script.Parent.Position) for k, i in ipairs(area) do ..... Idk how to continue. Basically check the Positions of each of the bricks within the certain region, and if there is a direction that isnt accounted for, it generates more parts... end end script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
|
| 20 Sep 2013 05:58 PM |
| So, infinite generation is practically impossible? |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 20 Sep 2013 06:03 PM |
Well with the original way, yes. Anaminus has done it before, so it is possible, just not in this way. I'm sure my way isnt exactly efficient either.
Another approach is to use a while loop, and if the character's Torso Position approaches the edge, it generates more bricks.
A third (and probably not what you want) way is to teleport the character to the other side :3 |
|
|
| Report Abuse |
|
|
tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
|
| 20 Sep 2013 06:05 PM |
Holy crap... I JUST DID IT! One problem though... it dosen't stop when it gets far away from the player, so it's a total lag fest... but this is what I did:
IX = 0.25 IZ = 0.25
while true do wait(0.1) IX = IX+1 IZ = IZ+1
for x = -IX, IX, 1 do for z = -IZ, IZ, 1 do local q = game.Lighting.ChunkPart:clone() q.Parent = Workspace q.CFrame = CFrame.new(8*x, y, 8*z) end end end |
|
|
| Report Abuse |
|
|
tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
|
| 20 Sep 2013 06:11 PM |
Modified it a bit...
IX = 1 IZ = 1
while true do wait(0.1) IX = IX+1 IZ = IZ+1
for x = -IX, IX, 1 do for z = -IZ, IZ, 1 do local q = game.Lighting.ChunkPart:clone() q.Parent = Workspace q.CFrame = CFrame.new(8*x, y, 8*z) wait(0.0001) end end end |
|
|
| Report Abuse |
|
|
tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
|
| 20 Sep 2013 06:12 PM |
| It works, except for the fact that it overlaps parts... any way to fix this? |
|
|
| Report Abuse |
|
|
|
| 20 Sep 2013 06:17 PM |
| Raycast around the area before you create it. If theres a part already, just ignore it. |
|
|
| Report Abuse |
|
|
tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
| |
|
|
| 20 Sep 2013 06:21 PM |
local part,pos = game.Workspace:FindPartOnRay(Ray) Ray.new(Vector1,Vector2) Vector1 should be above the part position Vector2 should be below.
Check if the part is nil and place the part if it is.
|
|
|
| Report Abuse |
|
|
|
| 20 Sep 2013 06:21 PM |
Made a few mistakes there
local part,pos = game.Workspace:FindPartOnRay(Ray.new(Vector1,Vector2))
|
|
|
| Report Abuse |
|
|
tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
|
| 20 Sep 2013 06:22 PM |
| How do I incorporate this with what I have? |
|
|
| Report Abuse |
|
|
08C
|
  |
| Joined: 26 Jan 2013 |
| Total Posts: 847 |
|
| |
|
tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
|
| 20 Sep 2013 06:36 PM |
....
How are you suppose to learn if you never take risks? I'm not just gonna quit right in the middle of the road! When I finally get the base spawning out of the way, I can take care of the rest with my own knowledge!
Go offend people somewhere else... >:( |
|
|
| Report Abuse |
|
|