1. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice
  2. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  3. We’re giving 2017.1 beta testers a chance to win t-shirts and a Nintendo Switch. Read more on the blog.
    Dismiss Notice
  4. Unity 2017.1 beta is now available for download.
    Dismiss Notice
  5. Unity 5.6 is now released.
    Dismiss Notice
  6. Get further faster with the Unity Plus Accelerator Pack, free for new Unity Plus subscribers for a limited time. Click here for more details.
    Dismiss Notice
  7. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  8. Learn how you'll soon be able to publish your games to China in four simple steps with Xiaomi. Sign up now for early access.
    Dismiss Notice

After playing minecraft...

Discussion in 'General Discussion' started by jc_lvngstn, Oct 8, 2010.

  1. Taintspore

    Taintspore

    Joined:
    Sep 29, 2009
    Posts:
    185
    Not sure why the shading isn't going right. I've been using the built in lighting system so far. Still haven't got around messing with materials yet. I think either Kiyaku or Beezir will have to help with that. I can take a look at the code you posted but I'm not too confident I'll be able to figure it out.

    Hrm... not sure how to help with the init cost. When you need to reinit don't instantiate a new prefab :)

    I'm getting the same thing where some chunks don't generate their meshes, which is weird because that isn't threaded and the mesh generator is called when the chunkdata comes back from being processed. I'll take a look at which queue I'm using, I thought it was the threadsafe one but I'm not sure.

    Update:

    Warning about the updated webplayer, same as before with the falling through unfinished chunks at the beginning (hit E) only now don't move around (WASD) until the terrain is done or there'll be a null exception and the thing'll stop generating terrain. Still need to stick in a loading screen but I like watching it generate so I've been putting it off.

    Also, if you're at a chunk boundary and dig, you can make holes into the side of the chunk you're digging next to. Should have that fixed soonish, need to focus on work the next few days.

    Edit:
    I'm using the threadsafe queue and I still get some chunks not regenerating their meshes. I'm at a loss as to why because the code is basically:

    Code (csharp):
    1. Get processed chunk from Queue
    2. Create mesh for chunk
    Don't know why it wouldn't tell all of them to do it.

    Oh, before I forget, I'm almost certain you can drop optimize because of the way we do our meshes. Because the no two square faces share any vertices I don't think optimize can do anything, we've already got a bunch of two triangle triangle strips. If you have longer strips then it might help, but IIRC from your code you do it more or less the same way Beezir and I did. Although Beezir didn't forget to not double up on the two shared verts per square like I did :p

    Update:

    New Webplayer in two varieties:
    Links removed (I broke it)

    All chunks (should) regenerate their mesh properly now as you wander around.
    Still haven't fixed the problem with holes being created by digging. Easy fix (lol, I hope anyway). If I have time to fix it today I'll put up a new player.

    Chunks go from -64 to 64 with the water level showing where the zero level chunks are.
     
    Last edited: Oct 17, 2010
  2. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,486
    @Taintspore,

    I think the holes created by digging, where you see emptiness when you dig across...is because you are digging into another chunk, and you haven't told that chunk to regenerate? I JUST now fixed the same problem in my code! :D

    I'm about have an update to show, just a few more tweaks. For some reason, I can't get the charactermotor to move my character any direction but north, south, east or west...which is AGGRAVATING.
     
  3. Taintspore

    Taintspore

    Joined:
    Sep 29, 2009
    Posts:
    185
    Yep yep, that's the problem, I had it doing that before (3d linked list for chunk neighbour access). I disconnected that part after I set up the threading. Should be easy to hook back up, just need to make sure that it stays in synch with new chunk strips.

    Are you using a stock character controller?
     
  4. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,486
    I figured it out...I had the mouselook script on my camera, instead of my player.
    /bonk
     
  5. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,486
    Here's the latest stuff:

    http://www.filefactory.com/file/b3ffce5/n/MineClone.exe

    You can't start digging until initial world creation is complete (hence the Please Wait). But the worlds seems to generate pretty quick.

    Next steps:
    Properly shade the darn blocks!
    Add in infinite terrain generation
    Generate a better looking terrain
     
  6. Taintspore

    Taintspore

    Joined:
    Sep 29, 2009
    Posts:
    185
    You're missing the data folder.
     
  7. CaptainKiyaku

    CaptainKiyaku

    Joined:
    Feb 8, 2009
    Posts:
    323
    Here is my version:

    16x16 Chunk World

    Same game, at the beginning it's filling the starterzone with the simplex noise so it takes a few seconds. After that it generates the chunks.

    Once that's done, you can control the player.

    Press e if you ever fell down
    Left click to remove a stone
    Right click to place a stone (currently only one type, i disabled the toggle through stones function in this build)

    Note: When a new chunk row is generating and you remove/place a bock, it will wait until the row is done before showing the changes. I will have to change that later on too.

    I also have to add the "check your neighbours" system to the new threading system, i will do that next :)
     
  8. Taintspore

    Taintspore

    Joined:
    Sep 29, 2009
    Posts:
    185
    Very nice Kiyaku. I really need to get the texture code done, it's way easier to see in yours because of the colour variation. Mine does neighbour checking now but I made a mistake and now if you're tunneling and new sections page in you can end up with a solid wall the way you came but it appears as a hole in the mesh. Shouldn't take long to fix but I'm going to take a break for now.
     
  9. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,486
    Ok, I'm a little puzzled then. I created a build, I thought that packaged everything up in one exe?
     
  10. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,486
    I like your textures, Kiyaku! Very nice
     
  11. CaptainKiyaku

    CaptainKiyaku

    Joined:
    Feb 8, 2009
    Posts:
    323
    Oh the textures are not made by me though, should have mentioned that hehe.
    They are from a user texture pack for minecraft called "Doku's RPG Textures". I will replace them with my own soon.

    But yeah adding a texture code for the meadow was fun, and it looks so much better when there is just meadow at the top and then only dirt on the side (except for the top row which has a little grass on it too).
     
  12. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,596
    no definitely not.
    the exe does not contain anything from the game.

    you need to copy the whole folder created, the exe on itself, the player, is useless actually
     
  13. Taintspore

    Taintspore

    Joined:
    Sep 29, 2009
    Posts:
    185
    Dreamora beat me to it. I don't think the exe changes at all (unless you remove parts of the engine, can you do that outside unity iOS?).

    I updated the player again, I think I have the holes fixed. If anything blows up or doesn't work right let me know. I think this is the 'final' at least for the terrain generation system. I'll keep playing with the generator to get more interesting terrains for sure.

    <links removed>

    So now (hopefully) onto proper texturing and chunk saving loading. Buuuuuut..... maybe explosions first :)


    Edit: Nix that... big bug in the mesh generator.
     
    Last edited: Oct 17, 2010
  14. Taintspore

    Taintspore

    Joined:
    Sep 29, 2009
    Posts:
    185
    Bah, I somehow completely screwed it up.

    I wanted to rewrite it anyway, the code was getting pretty fragile. I'll sleep on the code design for tonight then do the rewrite. Now that I have a pretty good idea of what I'm doing it shouldn't take too long.
     
  15. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,486
    Here's a little something I put in, I figure it will come in handy for others: A handy way to draw the closest chunks first, and move outward.

    Most of the code below is looping to generate the chunks. The sorting portion is quite small.

    The CreateMapChunksForGeneration actually creates the instances of my Chunks. It assigns them their coordinates (1..16, 1..16, 0) and adds them to a sort list.
    I then sort the list based on the chunks' distance from the center of the map, and queue them up for terrain generation. That's the part I figured might be helpful to others. However you handle your terrain generation and such, at some point you'll probably have a list of chunks for a new region the player has moved into or such, and are going to submit them in a list for terrain generation. This method of sorting them may be handy.Unity 3.0 required.


    public static void CreateMapChunksForGeneration()
    {
    List<ChunkData> chunksSortedByDistance = new List<ChunkData>();
    for (int x = 0; x < World.WidthInChunks; x++)
    {
    for (int y = 0; y < World.HeightInChunks; y++)
    {
    for (int z = 0; z < World.DepthInChunks; z++)
    {
    // Create instances of our chunks, add them to the map array,

    ChunkData chunk = new ChunkData(x, y, z);
    World.Chunks[x, y, z] = chunk;

    // Add them to our sort list
    chunksSortedByDistance.Add(chunk);
    }
    }
    }

    // Let's sort them by their distance from the center of the map
    Vector3 mapCenter = new Vector3(World.WidthInChunks/2, World.HeightInChunks/2, 0);

    // sort them now, by distance
    chunksSortedByDistance.Sort((firstChunk, secondChunk) => ChunksComparedByDistanceFromMapCenter(firstChunk, mapCenter, secondChunk));

    // Now queue them up
    chunksSortedByDistance.ForEach(chunk => TerrainGeneration.Enqueue(chunk));
    }

    // this is the actual comparison method that compares them by distance
    private static int ChunksComparedByDistanceFromMapCenter(ChunkData firstChunk, Vector3 mapCenter, ChunkData secondChunk)
    {
    return Vector3.Distance(
    new Vector3(firstChunk.X, firstChunk.Y, firstChunk.Z), mapCenter).
    CompareTo((int)Vector3.Distance(new Vector3(secondChunk.X, secondChunk.Y,secondChunk.Z), mapCenter));
    }
     
    Last edited: Oct 18, 2010
  16. CaptainKiyaku

    CaptainKiyaku

    Joined:
    Feb 8, 2009
    Posts:
    323
    Hey great, thanks for that!
    It's really generous of you and it will definitely come in handy! :D
     
  17. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,486
    I have a question the rest of you working on this...
    When a player moves into another 'chunk', requiring the engine to load another row or column of chunks in order to extent the map...

    Are you at some point "shifting" the player and map back to 0,0,0 world space, or are you allowing the player and terrain to extend infinitely into Unity's world space?
    The reason I'm asking is, Unity stores position values as floats...which at some distance doesn't give enough precision. It looks like you can go on for about 10 million units in any direction.
    Is this the case? While yeah, that's a long way...a determined person could do it.
    Anyone foresee this as a problem?
     
  18. CaptainKiyaku

    CaptainKiyaku

    Joined:
    Feb 8, 2009
    Posts:
    323
    Hm haven't thought about this yet but i just let it move on and not resetting it back to 0,0,0.

    I think i will ignore that for now. I don't think someone will ever move that far. If so, i can still add a fix for that hehe.

    The reason why i won't do that is cause i want to add multiplayer. And i think it could cause some problems if you move the world back to 0. I don't know, i will think about it a bit.
     
  19. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,596
    10million?
    you can be happy if you can go 100k due to restrictions on trigo and zbuffer :)

    I wouldn't shift the player and world at some point, I would actually continously move the world inverse to the player direction and keep the player fixed on the x-z axis, only moving him on the y one (as you don't go far up / down normally)
     
  20. Taintspore

    Taintspore

    Joined:
    Sep 29, 2009
    Posts:
    185
    In mine the player is never more than 16 away from the origin (except vertically). When the player attempts to leave that area around the origin everything moves backward and new terrain is created in front of the player.

    Should still work for multiplayer, the server really doesn't need to keep track of everything. Much of the world is stored in the seed value (all of it but changes made by the player)

    Edit:

    I "fixed" it. Still need to work out what's going wrong with the digging code and I want to change the how the noise/mesh/render systems work but you can wander around to your heart's content (so long as you wait for the map to finish loading :p) I've disabled digging for now because there's something wonky with translating the 'dig ray' collision to the voxel space of the chunk. Should be simple but I stared at this all day before noticing/breaking it, then I was stuck in the lab for a few hours working on some school related stuff (funnily enough it's a grad-course on parallel computing). So now I'm fried and can't think straight. Anyway, here's the 'fixed' players.

    16x16
    32x32

    WASD to move.
    Q to toggle cursor lock.
    E to pop back up (in case you fall through or you miss the terrain as it's being generated at the beginning)


    In mine, eventually the noise generators will more or less explode because of floating point errors. This is a documented problem in MineCraft as well. I think though mine will rollover and produce still glitchy terrain until you get back to non blowing up the generator numbers but I'm not sure, I could always set the initial offsets to be around the min/max values for ints and see. If it does rollover, then it would be like a finite version of the projective plane (opposite ideal points are really the same point) so it would wrap. Hrmmmm, I think I'll test and see what happens. If you don't hear from me for a week I melted my computer.

    edit:Hrm... at x,z=int.MaxValue the numbers get so garbled it can't put the chunks into the right spots so it ends up breaking. I'll try walking there from close to the max.

    ...


    Nope, still breaks. I got it to generate some but it looks all wonky. Sort of like the MC video.

    Must investigate.
     
    Last edited: Oct 18, 2010
  21. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,486
    I've got to think on the whole move the player vs move the world thing...I didn't even think about the zbuffer and such. If that's the case...then the distance someone could move before big problems kick in is going to be very limited.

    I had some head scratching moments with my digging code too...should be easy right? Remove block, redraw chunk. But Unity calling the chunk prefab's update method before my threads were done with it were causing some issues. And it's still a tiny bit glitchy.

    By the way, can't play your 32x32 one, I fall down before the terrain is there :)
     
  22. Taintspore

    Taintspore

    Joined:
    Sep 29, 2009
    Posts:
    185
    I've always heard that you should never stray 10k units from the origin because things starts to shake, first with Torque then later with Unity. IIRC it's because of floating point errors.

    Hit E and you'll pop back up. Might have to click to capture the mouse. Q toggles the cursor locking and hiding.

    Digging was simple until I broke it :p
     
    Last edited: Oct 18, 2010
  23. Artimese

    Artimese

    Joined:
    Nov 22, 2009
    Posts:
    794
    Wow honestly I dont see what the big deal is with this game, its terrible... I played it for 10 minutes then got bored and quit, I dont see how its addicting, not to mention the horrible visuals and annoying music (except the background music that plays during the day).
     
  24. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,486
    Here's what I find so attractive about minecraft.


    It's something that doesn't require a 50 man team and tens of millions of dollars.
    It's a 3-dimensional world you can carve and expand upon.
    It has random but elegant and sometimes epic landscapes
    Exploration
    Adventure
    Crafting
    You gotta respect that something so simple...has been so successful. Notch won the Indy lottery, in my opinion. /Salute!
    Frankly...a 3D blocky landscape, to me, has more awesomeness is some ways than any gorgeous 2.5D landscape.

    It's the sandbox nature of being able to change the entire world, if you want. This really fires my imagination. So what if the graphics are "chunky"? That has no effect on my imagination, in fact if anything it enhances the artistic presentation and experience. I like the unique style (oddly enough, my 7 yr old daughter doesn't like the blocky landscape. )

    Could it be more? Absolutely! Hence the reason so many now are embarking on their own efforts.
     
  25. Artimese

    Artimese

    Joined:
    Nov 22, 2009
    Posts:
    794
    IF the game looked better graphic wise, then maybe my attention span for the game would have been longer, but I don't expect that to happen because as it is it was kind of laggy with the pixilized graphics, cant imagine how it would have been with better resolution textures and meshes.
     
  26. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,486
    @Taintspore sorry, now that you mention pressing E, I recall a previous post where you mentioned this.

    So...it looks like I'll either need to "shift" everything back the origin occasionally, or I'll have to keep the player in place and move everything else.

    I'm going to try to regularly make my codebase available to others, hopefully it will be of some assistance and maybe even get me some suggestions on how to improve things. As soon as I get my "endless" terrain generation in place, I'll post another download link.

    After I get what I feel like are the basics for a minecraft "template", I'll stop because at that point I'll be adding my own unique features.
     
    Last edited: Oct 18, 2010
  27. CaptainKiyaku

    CaptainKiyaku

    Joined:
    Feb 8, 2009
    Posts:
    323
    I guess i'll have to add the "go back to zero" function too and i probably go with dreamoras suggestion to move the world, just because it reminds me of Futurama where they explain that the spaceships engine moves the universe around them, not themself, and i love that idea hehe.

    The addictive part about minecraft (at least for me) is to survive and to build whatever you want. it's like playing with lego or building a fort with chairs and pillows :D

    You just loose the motivation later on cause there is nothing new. That's why i would like to create something simliar just with a different approach and goal, and it's just for fun so i don't really plan to release it (yet 8D)
     
  28. Taintspore

    Taintspore

    Joined:
    Sep 29, 2009
    Posts:
    185
    Good explanation Kiyaku

    The motivation loss because of the lack of goals is exactly why I'm trying this. I'm hoping to do a 'generated story,' it won't have the best plot but there will be goals that vary based on the world's seed.
     
    Last edited: Oct 18, 2010
  29. Nikolay116

    Nikolay116

    Joined:
    Mar 21, 2010
    Posts:
    421
    are you guys trying to make unity minecraft here basically?
     
  30. Taintspore

    Taintspore

    Joined:
    Sep 29, 2009
    Posts:
    185
    I think we're going with something like "duplicate and expand" (similar relation with minecraft and infiniminer). I'm not that interested in the crafting system, I'll have one for somethings but it'll be more about creating through improvisation rather than creating through invention. Er.. I'm not sure I articulated that well...
     
  31. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,486
    One of the big reasons I'm creating a clone is one that Taintspore and Kiyaku already mentioned...the game left me wanting to add more of my own ideas. I feel it's opened up a whole new genre in a way, like Tower Defense did.

    And (I keep telling myself this, I hope it's true) I keep thinking that once the framework is in...the infinite world generation, digging, basic crafting, basic monsters, etc...that adding my own unique ideas will be much easier.
    Yeah.
     
  32. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,486
    Regarding this...
    seeing as how we are only using the depth "layer" of say...128 blocks for the noise generation, once you approach the x,y limits...why not swtich back to around 0,0 and use the lower (or higher) layers of noise data?

    For example...let's say that at 1000 units along the x axis, floating point issues appear.
    Ok...so then we just have code that blends the values of (x=999 and x=0) to supply the values for 1000.
    Anything over 1000...we instead subtract 1000, and use a z value of +128. giviing you a whole new "layer" of noise to use.

    That make sense?
     
  33. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,486
    I realized a very quick way to handle moving the world, and everything else, around the player.

    My player exists at the top level of the heirarchy.
    The world also exists at the top level of the heirarchy.
    Everything else I add to the world (pretty much just chunk meshes for now) gets added as a child of the world gameobject.

    If my World script, in the Update function, it checks to see if the player has moved away from the origin. Actually, it disregards the y axis, it really only cares about the x and z origin.
    If so, it moves the world in the negative by the same amount. That's pretty much all it takes.

    Here's the method I call from Update():

    private void CenterWorldAroundPlayer()
    {
    // If the player hasn't moved...don't worry about moving everything else.
    if (Player.transform.position == new Vector3(0, Player.transform.position.y, 0))
    {
    return;
    }

    transform.position -= new Vector3(Player.transform.position.x, 0, Player.transform.position.z);

    Player.transform.position = new Vector3(0, Player.transform.position.y, 0);
    }

    The only problem I am having: I get a jitter after a while, in the world coordinates. you can see it happening in the inspector. I don't know why this is, unless it's because of floating point errors that accumulate. In that case...I'm not sure how to fix them :(

    Here's a link to my current codebase, thought blocks are disabled and infinite terrain isn't there either:

    http://www.filefactory.com/file/b3g2h00/n/MineClone2-Jittery_World.unitypackage

    Edit: Figured out the jigger.
    It's the Moving Platform setting in the Character motor. Makes sense now, I guess :\
     
    Last edited: Oct 19, 2010
  34. Taintspore

    Taintspore

    Joined:
    Sep 29, 2009
    Posts:
    185
    Gah! That one screwed with me too!

    Originally every time I would shift the terrain the player would go flying off backwards. Glad you figured it out, I had completely forgotten about that.
     
  35. Guru

    Guru

    Joined:
    Apr 30, 2010
    Posts:
    118
    Just wondering if anyone has made any progress with this lately. I am currently making some modifications based off the Stacker, as well code others have kindly posted in this thread, and was wondering if those of you that were working on this still are.
     
  36. Taintspore

    Taintspore

    Joined:
    Sep 29, 2009
    Posts:
    185
    I still am, however slowly. I'm thinking of taking a slightly different direction because of technical limitations. Depends on how my LOD system goes. When I get it up and running I'll post a web player.
     
  37. CaptainKiyaku

    CaptainKiyaku

    Joined:
    Feb 8, 2009
    Posts:
    323
    Yes i will continue with my project as well, just have to work on 4 other projects for clients so i don't really have much time right now.
    Still have to fill up the holes when generating the terrain.
     
  38. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,486
    I'm still working on it. Lately I've been working on
    Better looking terrain (pretty happy with this)
    infinite terrain generation
    better dirt and grass textures, grass on the top layer

    What I will be working on soon:
    CAVES/cliffs - I haven't had much luck with this yet, my attempts so far look like swiss cheese :D
    different types of ores/stuff in the ground
    finishing up removing and adding blocks, which will require some sort of basic inventory

    After that:
    Basic friendly/unfriendly critter AI
    terrain lighting
    light sources such as torches, fires, etc
     
  39. Scott M

    Scott M

    Joined:
    Jul 13, 2005
    Posts:
    23
    I've been bitten by the Minecraft bug, and, for many reasons, it's inspired me to download Unity and take a crack at my own version (I haven't used Unity since the first version). So I've really appreciated your guys' explorations here. I'm a bit behind y'all in implementation, but have consumed all I could find on the NBT format, chunks, simplex/perlin noise, and procedural stuff in general. I ran Minecraft Overviewer on a world where I hadn't moved the FOV or my player to see what gets generated on initial load, etc, etc. Now I'm just getting back up to speed with Unity.

    Anyway I'll share stuff if I find anything interesting and I look forward to further insights and updates from you guys.
     
  40. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,486
    Should have something up in a day or so, I had to make some improvements/simplifications on my threading code for terrain and mesh generation.
    I -really- wish Unity 3.0's debugging capabilities worked. Debug.Log with multithreaded code is rough.
     
  41. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,605
    jc_lvngstn explained very well the appeal of Minecraft and you saying you would like it if it looked better just sounds ignorant to me. I really appreciate the simple graphics and it encourages you to use your imagination more when playing. There's also some great features in there like in the crafting how you place your ingredients to represent the object you're making. Also the simple graphics allows the developer to approach things like flowing water in a completely unique way. When I start up Minecraft I see the graphics as pretty epic in fact. When you discover things like this it just makes me want to explore the world even more:

    [​IMG]
    Maybe there's a dungeon down there with dangerous monsters and huge amounts of loot or maybe there's a rich gold vein in there? And because it's randomly generated you know there are millions of other completely unique locations and never before seen scenery out there. Compare this to a game like World of Warcraft where everyone has seen everything, always.

    Countless Unity clones of Minecraft has shown that you can easily have good graphics in a Minecraft game so if he wanted to he could. Also you can download different texture packs for the game including high res textures.

    But there's some amazing graphical features in Minecraft as well. For example how the dynamic lighting fills a cave with light the moment you break through to the surface or how water and lava flow through the world and cave systems, how crops grow, soil gets wet etc. etc. etc.

    This being said I became bored of Minecraft after just an hour, but that's because I just don't think there is enough content in there as of now. I don't care so much for just the building aspect of the game by itself, but if he expands the survival/adventure/rpg part of it I can see this game having the potential of becoming massive like World of Warcraft or Runescape. Hell, it's already got 1,5 million registered users.

    I also love how hardcore the game is. The first time I started it up I was slaughtered. The second time I managed to build a small house, but was still killed in a cave. The third time I got pretty far and even made myself a full set of iron armor just by experimenting with the crafting, but then I broke through to some lava and died. I love how, if you haven't prepared yourself (like I hadn't), you will lose everything. Games these games are so simple, so user friendly there's almost no challenge left.
     
  42. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,486
    Earlier in this thread, the topic came up about moving the character around the world, vs moving the world around the character.
    I'm now questioning if moving the world around the player is really necessary.

    My world currently is split into chunks, each chunk having a mesh for the terrain generated from the blocks' visibility.
    Now, let's say my player moves far enough east. At this point, the game draws another column of chunks to the east, and will drop the westmost column of chunks.

    So...no matter what, unity objects are only draw within the world's distance around the player.
    So, if my player is at 0,0,0 and I draw a chunk at 100,0,0, is that really any different to Unity than my player being at 10000,0,0 and drawing the chunk at 10100,0,0?

    It seems like Unity would just take the relative difference between my camera and the objects being drawn, rather than freaking out and saying "OMG stuff is being drawn at 10100 CRASH".

    Or, is this not the case? The only reason I'm asking this is, adding in a world offset that I have to keep track of adds some complexity. Also...even if I DO keep my player at 0,0,0...the world parent must still be moved in the opposite direction. Even though my player may STAY at 0,0,0, the world parent will eventually be moved to -10000,0,0.
    Hope this makes sense.
    Any clarification would be welcome :)

    Also...I realize that at some point, the floating point math will fail. I'm not talking about that...I think that's a bridge I may not have to cross just yet.
     
    Last edited: Oct 25, 2010
  43. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,596
    yes moving the world is required, as you have like 40k range away from 0 in any direction, if you are lucky, beyond that you start to get z buffer issues and rotation jitter due to float instability. with view ranges as minecraft has it, the problem potentially comes up even earlier
     
  44. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,486
    Ok, so this is hard for me to visualize, my brain struggles with abstraction.
    My chunks and creatures (basically anything not the player) are children of a world object in the heirarchy, This makes all of their coordinates local to that world objects position. So if my world extents are 256x256, nothing will have coordinates outside of that range. My world parent object is pretty much always at 0,0, because my player is moving.

    My earlier idea was to keep my player at a fixed location (128x128), and move the parent world object position in the reverse direction instead...but this really isn't right, because the parent world coordinates will eventually go too far (even though the children objects will still be local).

    So it seems the only way to do this is to move each individual terrain mesh and critter/entity in the world by the correct amount. I can either have a big honking loop that loops through each mesh and creature and moves them the correct amount...or I can just store the amount to move them in a static variable somewhere, and have the script of each chunk and creature move itself by that amount in the reverse direction.

    Any suggestions on this? Am I making this too complicated, because it seems so. Like I said...for some problems like this, my brain just struggles :)
     
  45. Taintspore

    Taintspore

    Joined:
    Sep 29, 2009
    Posts:
    185
    This is how I do it:

    The terrain manager is the parent of all the chunks and doesn't move. It stores chunks in 3d List<>. The player is not a child of the terrain manager. When the player gets far enough from the origin (chunk size along corresponding axes) the terrain manager internally shuffles the chunks backward (relative the the player), sets their transform positions based on index, then generates the new noise and meshes with the threaded code along the 'new' strip of terrain. The player is shifted back by a distance of one chunk.You can see it in action in the webplayers I posted before: the last stip behind you will pop in ahead of you before the noise and meshes can be generated.

    Everything is pretty trivial in terms of performance except for the noise. Oh, forgot to mention I keep x,y,z offsets (ie number of chunks to the "origin") so that the noise is generated correctly and to make mapping chunks to indices and vice versa in the lists easier.

    Doing it this way keeps the floating points for rendering and physics stable. The problem is that in the generation code the offset will eventually make the floating points unstable and the mapping fails or the terrain can get weird. In my case the terrain gets a little weird then the mapping fails at an offset of about 200 from the min and max values of an int.
     
    Last edited: Oct 25, 2010
  46. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,486
    Ok, so it sounds like:
    Shifting everything in the opposite direction of player movement isn't that big a deal in terms of performance.
    From what I gather so far...the only reason to keep up with the actual offset is for noise generation
     
  47. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,486
    Here's my latest build. A couple of issues, one you will notice right off the bat.
    First, it only adds new terrain as you move to the east, not that gameplay gives you directions :)
    I am not tiling my textures right, or doing the uvs right or something. There are lines between the textures.
    Right now, it moves the player, not everything else...that will change later.

    I'd like to link the web player, but I'm too dumb to figure out how to put it somewhere. The web site I got through justhost doesn't seem to allow the unity javascript file...so I'm at a loss there.

    Here is the link:
    http://www.filefactory.com/file/b3hec1h/n/MineClone.unitypackage

    As usual, I welcome any suggestions or questions
     
    Last edited: Oct 26, 2010
  48. CaptainKiyaku

    CaptainKiyaku

    Joined:
    Feb 8, 2009
    Posts:
    323
    You can also host it at dropbox i guess, i saw other people doing that before.
    Webplayer would be much nicer ^^
     
  49. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,486
    Actually, I do have a dropbox account I can use.
    Hmmm...
     
  50. CaptainKiyaku

    CaptainKiyaku

    Joined:
    Feb 8, 2009
    Posts:
    323
    I finally finished the "fill the holes" part, though right now i have my old method again, first filling the dictionary with the noise, then create the meshes for the starterzone so i can access the neighbours. Couldn't figure out how to generate noise for one chunk -> generate chunk -> ask if neighbour has a stone -> if not generate noise for the necessary chunk and read out the input. It somehow broke my thread and stopped afterwards. So yeah, i guess i have to re-organize how to create things to do this, but for now this is fine too.

    I have another annoying problem though, my main thread does not stop after quitting. I tried to call "getMapThread.Abort()" when i stop the editor, but it keeps on running and prints logs into my Editor log.
    This is the thread:

    Code (csharp):
    1. void ProcessChunks()
    2.     {
    3.         Debug.Log("Start processing Chunks...");
    4.  
    5.         ThreadPool.QueueUserWorkItem(state =>
    6.         {
    7.             while (true)
    8.             {
    9.                 while (chunksToProcess.Count > 0)
    10.                 {
    11.                     ChunkData chunk = chunksToProcess.Dequeue();
    12.  
    13.                     GetMapThread(chunk);
    14.                     chunksToCreate.Enqueue(chunk);
    15.                 }
    16.                 Debug.Log("Start creating Chunks...");
    17.                 while (chunksToCreate.Count > 0)
    18.                 {
    19.                     ChunkData chunk = chunksToCreate.Dequeue();
    20.  
    21.                     GenerateMesh(chunk);
    22.                 }
    23.             }
    24.         });
    25.     }
    So even when i stopped the editor it still writes "Start processing Chunks..." into the log.
    How can i actually kill it?