Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Uniblocks: cube-based infinite voxel terrain engine

Discussion in 'Assets and Asset Store' started by RawLionWorkshop, Feb 2, 2014.

  1. Dunkelheit

    Dunkelheit

    Joined:
    Sep 3, 2013
    Posts:
    81
    Hi maap,

    I had tested your Voxel Engine from dropbox you have published and I know that you know about some glitches around, like the "gaps" between the voxel blocks as well, but I have noticed another thing, the lighting handler is missing, if I deeply dig the terrain I can easily go through it inside without any light resource, that is bad IMO. So, the engine is promissing and unfortunately now it needs some new features to worth the price announced, but don't be down and keep it up, please, maybe soon it will become the best Unity voxel engine availabel.

    Below you can figure out what I'm talking about.

    $voxel.jpg
     
  2. RawLionWorkshop

    RawLionWorkshop

    Joined:
    Jan 29, 2014
    Posts:
    206
    I really don't see any problems here, aside from the gaps (again, either disable anti-aliasing, or force adaptive anti-aliasing in your graphics card driver settings).
    Maybe you mean the shadow? If so, that's intended, the demo scene is lit by a single directional light which casts a hard shadow.
     
  3. Rod-Galvao

    Rod-Galvao

    Joined:
    Dec 12, 2008
    Posts:
    210
    @Dunkeheit

    You can add a second weaker directional light upward.
     
  4. Rod-Galvao

    Rod-Galvao

    Joined:
    Dec 12, 2008
    Posts:
    210
    Hi maap,


    I have some suggestions to Uniblock's code so it doesn't need to be changed by your clients.


    The first one is related to world saving/loading. If the game don't want to persist the world data you could change these lines in Chunk.cs.


    Add this line after, say, line 12:
    Code (csharp):
    1.     public bool PersistData; // if we should load/save the chunk's data
    2.  
    Change (from original) line 58:
    Code (csharp):
    1.         else if (PersistData) {
    2.             if (GetComponent<ChunkDataFiles>().DataExists(ChunkIndex) == true ) {
    3.                 LoadVoxelData();
    4.             }
    5.         }
    6.  
    Change (original) line 224:
    Code (csharp):
    1.         if ((Application.isWebPlayer == false)  PersistData) {    
    2.  
    The second one is to avoid people editing the terrain generation line:


    So it becomes something like:
    Code (csharp):
    1.         GetComponent<AbstracrTerrainGenerator>().GenerateVoxelData();
    2.  
    Add a new class AbstractTerrainGenerator:


    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4.  
    5. namespace Uniblocks {
    6.  
    7.  
    8. public abstract class AbstractTerrainGenerator : MonoBehaviour {
    9.     public abstract void GenerateVoxelData ();
    10. }
    11.  
    12.  
    13. }
    14.  
    Now we can replace our ExampleTerrainGenerator script component, from the chunk prefab, with something like:


    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using Uniblocks;
    4.  
    5.  
    6. public class MyTerrainGenerator : AbstractTerrainGenerator
    7. {
    8.     public override void GenerateVoxelData()
    9.     {
    10.         Chunk chunk = GetComponent<Chunk>();
    11.        
    12.         // Insert your code here...
    13.  
    14.  
    15.         chunk.VoxelsDone = true;
    16.     }
    17. }
    18.  
    What do you think about it?
     
  5. RawLionWorkshop

    RawLionWorkshop

    Joined:
    Jan 29, 2014
    Posts:
    206
    Thank you for the suggestions, I'll definitely add them in the next update.

    I was actually trying to find an elegant way to allow users to change the terrain generator script without digging through the code, but it turns out you can't easily store a reference to a script in a variable, or at least I couldn't find a way to do it. I totally missed the inheritance solution though, and it certainly solves the problem nicely.
     
  6. DevMerlin

    DevMerlin

    Joined:
    Dec 21, 2011
    Posts:
    96
    Got the extension and I like what it does so far, but I am having a minor problem. I can only get this running within the Demo Scene, while after dropping the Engine into the editor, it produces.... a blank result. Nothing. Default Engine prefab settings. I keep comparing the demo scene and my scene and can't see any major settings differences at all.
     
  7. RawLionWorkshop

    RawLionWorkshop

    Joined:
    Jan 29, 2014
    Posts:
    206
    My best guess is that you don't have anything that would actually trigger the spawning of chunks in your scene. In the demo scene the player prefab has a ChunkLoader script which triggers the spawning of chunks around the player's position. You can also do this manually using ChunkManager.SpawnChunks(x,y,z). Check the documentation for more details.

    If this doesn't solve the problem I'll need some more information, a screenshot of the scene and engine settings would be best.
     
  8. DevMerlin

    DevMerlin

    Joined:
    Dec 21, 2011
    Posts:
    96
    That solved it! I feel a little bit stupid for not reading down. I do seem to have another problem though, everything is getting assigned to the GUI layer, which renders the chunks invisible due to the main camera not seeing that layer. How do I change the default chunk layer?
     
  9. RawLionWorkshop

    RawLionWorkshop

    Joined:
    Jan 29, 2014
    Posts:
    206
    I'm not entirely sure if this is what you meant, but you can change the layer of the chunk GameObject by editing the Chunk prefab (UniblocksObjects/ChunkObjects/Chunk). Sounds like a really strange problem though, it might be something else causing it... Let me know if you still can't fix it.
     
  10. DevMerlin

    DevMerlin

    Joined:
    Dec 21, 2011
    Posts:
    96
    Fixed again! Thank you, I have no idea why the chunk object tried to assign itself to the GUI layer. Would think it would've assigned itself to Default.
     
    Last edited: Apr 18, 2014
  11. DevMerlin

    DevMerlin

    Joined:
    Dec 21, 2011
    Posts:
    96
    I have one last question for you, maap. Would it be possible to grab a reference to all the voxels in a volume to alter them? Say... the area of a trigger.
     
    Last edited: Apr 19, 2014
  12. RawLionWorkshop

    RawLionWorkshop

    Joined:
    Jan 29, 2014
    Posts:
    206
    If your area is rectangular and oriented the same way as the voxels, you'll simply need to find the voxels at the corners of the rectangle, and iterate through all indexes between them. You can find the corners using Chunk.PositionToVoxelIndex for the positions of two opposite corners of the rectangle. Then, let's say your first corner is at -5,-5,-5 and your second corner is at 5,5,5. You'll need a triple nested loop to iterate through x,y,z values between -5 and 5, which will be the indexes of all voxels inside the area.

    It gets a lot more difficult if the area is of a different shape or orientation so I'd highly recommend to keep your triggers aligned with the blocks. But if you must use an irregular trigger, here's some ideas you could explore:

    For a spherical area, you could use the radius of the sphere instead of corners, but then you'd end up with a cubic area, so you'd have to somehow cut off the corners to get a sphere of voxels.

    For a rectangular area that's not aligned with the blocks... well, you'd probably need to iterate through each voxel within the bounding box of the area, and see if it falls inside the actual trigger, probably using the phyiscs engine to check for collision. Hopefully you won't actually need to do this though.
     
  13. DevMerlin

    DevMerlin

    Joined:
    Dec 21, 2011
    Posts:
    96
    Hey! I've gotten things mostly working, and running just right. I've got a couple of final questions though. Is it possible to refresh all of the existing active chunks in view? Basically, flush their data and redo the voxels. For the second question, can worlds be deleted from within the system if they exist?
     
  14. RawLionWorkshop

    RawLionWorkshop

    Joined:
    Jan 29, 2014
    Posts:
    206
    The easiest way would be to destroy all chunk GameObjects (find all GameObjects with the "UBChunk" tag), and then spawn them again.
    Or you can also grab all the chunks and do a Chunk.GenerateVoxels or Chunk.LoadVoxels, followed by Chunk.FlagToUpdate for all of them. However, using the second method you'll probably get a short freeze when generating or loading data for too many chunks in a single frame. The first method will distribute the load over many frames automatically.

    You can just delete the world folder, which will be at Engine.WorldPath. You can do that with Directory.Delete (Engine.WorldPath, true); You'll need to include a using System.IO; line in the script to use this.
     
  15. DevMerlin

    DevMerlin

    Joined:
    Dec 21, 2011
    Posts:
    96
    Oi! Okay, almost everything is working. The above suggestions were great and fixed that, but... I've got a headscratcher. I applied a custom texture atlas and it works, with the settings suggested for custom textures. However.. I'm getting strange "lines" every so often. These are not the Anti Aliasing lines, they can split the view up and down in only one area. I'm not quite sure how to fix this.

    http://www.teonnyn.com/gallery/goofs/Lines.png

    I outlined the artificat as it appears. It probably has something to do with my graphic over the one provided but I'm not quite sure what.
     

    Attached Files:

    Last edited: May 3, 2014
  16. RawLionWorkshop

    RawLionWorkshop

    Joined:
    Jan 29, 2014
    Posts:
    206
    I think you probably have mip maps enabled in your texture import settings. Make sure they're disabled, and let me know if that fixes the problem.

    Also, make sure all other texture settings are like in the picture on page 2 of this thread.
     
  17. DevMerlin

    DevMerlin

    Joined:
    Dec 21, 2011
    Posts:
    96
    Textures are 64x64, although I estimated and it should be able to handle 128x128 too. I've got an exact match on settings and actually eliminated all but one quality setting, with things disabled and set to basics. Mipmap settings are off, here's the actual:

    $Settings.png

    $QualitySettings.png
     
    Last edited: May 3, 2014
  18. RawLionWorkshop

    RawLionWorkshop

    Joined:
    Jan 29, 2014
    Posts:
    206
    Okay, I think the problem is that you have anisotropic textures forced on in your quality settings. Try setting that to Disabled or Per texture, it should fix the problem.

    If that still doesn't work, let me know if the problem happens even with the default texture, and also whether or not it happens in the demo builds.
     
  19. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    Hi, nice looking plugin. I have a couple of questions when you have spare time.

    1. Can you somehow associate gameObjects(like food, weapons, monsters, etc on blocks) to a chunk and save/load them when Uniblocks saves/loads a chunk?

    2. I've never seen it on MineCraft type voxel engine but is it hard to make it able to paint textures on blocks? or maybe texture blending with surrounded blocks? While I don't really think it's possible but I want to make blocks look less blocky if posbbile, like this(http://www.mapeditor.org/img/screenshot-terrain.png).

    3. Can you make plank(plate?)-size block or half-size block in Uniblocks, with correct collider?

    Thanks for your time!
     
  20. RawLionWorkshop

    RawLionWorkshop

    Joined:
    Jan 29, 2014
    Posts:
    206
    Unfortunately that's beyond the scope of this asset, so you would need a custom solution for saving and loading GameObjects, but it shouldn't be too hard to do. Each chunk has a unique index (x,y,z), so whenever a chunk saves or loads it's data you could simply save/load the GameObject data from a file corresponding to that unique index. The only challenge would be serializing the GameObject data for saving/loading from files, but I'm sure there are many existing solutions available for this.

    Seems like it would be pretty difficult to do. I'm sure it's possible, but it would require digging deep into the mesh generation code. Most likely you'd want to check every block face's adjacent blocks, and if they are different, you'd assign an extra "blend" texture on top of the block's face. Though that could get very complicated, because you'd potentially need to consider all adjacent blocks including diagonals, and there are probably lots of problems that you'd have to deal with on top of that.
    Maybe there is some simple solution to this that I'm missing, but I can't really think of an easy way of doing this...
    Of course you could also use a smooth voxel engine, which would eliminate the cube look completely, but I don't know if that's what you're looking for.

    Yep, in fact you can easily use custom meshes of any shape and size, including correct colliders.



    In other news, the first big update is now on it's way, currently awaiting approval. The biggest change is the introduction of multiplayer features, so look forward to that!

    After some consideration I settled on the default Unity networking to keep things simple, but with the help of the documentation it shouldn't be too hard to port it to a third-party solution, if needed.

    Also, please make sure to back up your project before upgrading to the new version, as there are some minor changes in the core files. The multiplayer features are of course completely optional and won't interfere in any way with the single player functionality.
     
  21. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    Thank you for the clear answer and congrats on new version!
     
  22. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    Hello again, do you think Uniblocks can work with Unity's terrain? I know this is a weird idea but using terrain as surface and blocks for buildings , artificial structures etc.... Since Uniblocks use unity's lighting and collider system,. I'm thinking it's not hard to do so, a bit worried about performance hit though...

    edit: the terrain should be flat, rendering anything above or below the terrain with uniblocks
     
    Last edited: May 20, 2014
  23. RawLionWorkshop

    RawLionWorkshop

    Joined:
    Jan 29, 2014
    Posts:
    206
    You could do that, sure. You can just put both Unity terrain and Uniblocks terrain into the scene, and they will work independently of each other. It would be essentially the same as using Unity terrain together with regular meshes.
    However, if you wanted to edit the Unity terrain at runtime, you would need a different solution for that.
     
  24. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    Sounds great. Thanks again!
     
  25. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    Unity terrain + Uniblocks worked great. I have another question.
    For my game, chunks don't have block unless blocks are generated by players so there's no lag related to building mesh. But watching at profiler, loading chunks still seem like a little heavy operation. I've tried changing values via engine window(chunk size, distance, mesh update limit etc) but can I further optimize chunk loading process?

    On the other hand, rendering blocks seem pretty fast. I was getting 1000+FPS in the demo scene and have almost no impact when using Uniblocks with terrain.

    One thing I'm trying to implement now is Inner Loading system from Dynamic Loading Kit described at page 7 in this manual . I think this will work great with Uniblocks
     
    Last edited: May 25, 2014
  26. RawLionWorkshop

    RawLionWorkshop

    Joined:
    Jan 29, 2014
    Posts:
    206
    Unfortunately, chunks will always be somewhat costly to load, even when they have no blocks in them, because each chunk has to load its voxel data from disk, which takes some time, plus the mesh generation process takes some time even for empty chunks.I think the only thing you can do here without heavily messing with the code is to set the "Chunk spawn limit" setting lower. This will reduce lag when loading, but also increase loading time.

    Also try reducing the "Chunk save limit" setting - it's possible that some of the lag from loading new chunks is actually caused by saving old chunks as they're being deleted.

    Actually, one more thing - if your chunks are mostly empty, it might be a good idea to actually increase the chunk size. That way you have less chunks overall, which means chunk overhead. In fact it's generally a good idea to keep your chunk size as high as you can before you run into lag from mesh generation.
     
    Last edited: May 25, 2014
  27. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    After playing around with the engine setting, loading spike(which really isn't big atm) seem to be almost gone. Reducing both chunk spawn limit and save limit worked, along with increasing the chunk size to 16 from 8. It's nice that Uniblocks has the ability to spread the costly process.

    Thanks for taking your time to give me the advice. I'll be sure to write a good review :p
     
  28. baustin27

    baustin27

    Joined:
    Feb 21, 2014
    Posts:
    12
    So im trying to make a voxel simulation of real seismic data, And I'm trying to use a cube as a trigger so that when the cube comes in contact with a block it hides the mesh renderer of the blocks that is in collision with and displays the blocks underneath.

    I have made a cube and written the script and put it on the cube that ontriggerenter disables the mesh renderer and ontriggerexit enables the mesh renderer.

    This works on other gameobjects and on chunks but i cannot get it to work on individual blocks. Is it possible to do what I am saying?
     
  29. RawLionWorkshop

    RawLionWorkshop

    Joined:
    Jan 29, 2014
    Posts:
    206
    The blocks themselves don't have their own mesh renderers, they are simply a part of their chunk's mesh, so disabling the mesh renderer will not work in this case.

    What you need to do instead is to temporarily change the block to an empty one. You can use the OnBlockEnter event to find the block that your trigger collided with. The documentation explains this in detail, and you can also check the DefaultVoxelEvents script for an example usage of OnBlockEnter (which just prints the block's index to the console on collision).

    Once you find your triggered block, simply change it to an empty one, and then when an OnBlockEnter is called on another block, you can restore the previous block to it's previous state.
     
  30. baustin27

    baustin27

    Joined:
    Feb 21, 2014
    Posts:
    12
    Thanks Maap, Another thing is im having trouble making setting the texture on a custom mesh, it only comes out brown, what am I missing?
     
  31. RawLionWorkshop

    RawLionWorkshop

    Joined:
    Jan 29, 2014
    Posts:
    206
    I'm guessing your mesh doesn't have correct UVs. The built-in texture mapping only works on cubes, so your custom meshes need custom UVs, mapped to the texture sheet you're using.
     
  32. Kilari

    Kilari

    Joined:
    Oct 20, 2013
    Posts:
    13
    I'm having trouble figuring out how to get a transparent water texture to work in this. You have pictures of water how I would want it in the asset store but I can't seem to reproduce it! Any help?
     
  33. RawLionWorkshop

    RawLionWorkshop

    Joined:
    Jan 29, 2014
    Posts:
    206
    The water in the pictures is just the standard Unity water which comes with Unity Pro (the free version also has water, but with less realistic shaders).

    If you want to have actual water blocks with partially transparent textures, that's going to be very difficult due to technological limitations. If you try to use a shader which supports partial transparency, you'll have problems with sorting (farther chunks might be rendered in front of closer ones, etc). The only transparency that works without any problems is full transparency (the Transparent->Cutout shaders in Unity).

    Basically, the most reasonable solution is to simply use a separate object with it's own water shaders, independent of Uniblocks, for example the default Unity water, or some other water solution.
     
  34. Kilari

    Kilari

    Joined:
    Oct 20, 2013
    Posts:
    13
    I was playing with assigning sub-meshes to allow water voxels with a different shader, however I ran into an odd issue with it and I'm not quite sure where it happens-

    I can place a water voxel with a different transparent shader just fine, and all the other blocks around it work fine- but as soon as i delete that water voxel on a seperate submesh then random blocks around it swap to the submesh! I've ran through all the engine code as best I could and I cant figure out why this is happening.
     
  35. RawLionWorkshop

    RawLionWorkshop

    Joined:
    Jan 29, 2014
    Posts:
    206
    I have no experience with submeshes at all, so it'll be really difficult for me to help you here. In any case, I'd probably need to see your code in order to find the problem, since I can't reproduce it if I don't know the exact changes you made.

    My only guess is the following line from ChunkMeshCreator:
    mesh.triangles = Faces.ToArray();

    According to the scripting reference:
    When you assign triangle array, subMeshCount is set to 1. If you want to have multiple sub meshes, use subMeshCount and SetTriangles.

    which means you'd need to use mesh.SetTriangles instead of mesh.triangles. If that's not the problem, maybe you could send me your code via email, so that I can take a closer look at it?
     
  36. Kilari

    Kilari

    Joined:
    Oct 20, 2013
    Posts:
    13
    I've since updated my project to your latest Uniblocks version so I've lost the exact changes I've made, however that is the lines I changed in the way you described. I'll look into re-creating what I had before, double checking the error, and then forwarding that to you soon.


    Edit: found a backup- The only changes I made were to change the mesh.triangles script to:

    mesh.SetTriangles(Faces.ToArray(), 0);
    mesh.SetTriangles(FacesTransparent.ToArray(), 1);

    And I made a secondary CreateFace function that simply added to a FacesTransparent array instead of the normal Faces array to push to the submesh. The original Faces array part (The original mesh) seems to work just fine, nothing buggy about it.
     
    Last edited: Jun 19, 2014
  37. RawLionWorkshop

    RawLionWorkshop

    Joined:
    Jan 29, 2014
    Posts:
    206
    Well, I think I've got a transparent submesh working fine, with none of the issues you described. Although it still doesn't actually solve the sorting problem I described previously. Occasionally, you'll get artifacts like these:
    transparency.jpg

    But then again, having just the water on a transparent submesh will make them less obvious, so perhaps it is a good enough solution.


    Here's all the changes to the ChunkMeshCreator that I've made:

    - Instead of creating a second CreateFace function, i just put this check in the original one, below the // add the faces line:
    if (Engine.GetVoxelType(voxel).VTransparency == Transparency.transparent) {
    and put the six Faces.Add (...) lines there (replacing Faces.Add with FacesTransparent.Add)
    then I put the original Faces.Add lines in an else block.
    Obviously you can use whatever if check you need there.

    - In the UpdateMesh function I added
    mesh.subMeshCount = 2;
    right after
    mesh.Clear();

    - I replaced mesh.triangles = Faces.ToArray(); with the two lines from your last post

    - and at the end, after
    Faces.Clear();
    I added
    FacesTransparent.Clear();


    So try this, and hopefully everything should work fine. If your problem still persists, it's probably somewhere on your end.
     
  38. Kilari

    Kilari

    Joined:
    Oct 20, 2013
    Posts:
    13
    Oh man, It was the FacesTransparent.Clear();!

    Thanks a ton! Gotta love when its something simple.

    Love this asset btw, giving it 5 stars right now, mostly because of the awesome support you have given.

    Mind if I ask where your goal to go with this next is, if anywhere?
     
  39. RawLionWorkshop

    RawLionWorkshop

    Joined:
    Jan 29, 2014
    Posts:
    206
    I'm glad to hear it's working, and thanks a lot for the rating and review!

    At the moment I'm taking a little break while I work on some other projects, so there are no major updates planned for the near future. However in the long term I would like to add some of the previously requested game-oriented features such as dynamic liquids, better terrain generator, etc.
     
  40. Rod-Galvao

    Rod-Galvao

    Joined:
    Dec 12, 2008
    Posts:
    210
    What is the preferred method for setting and getting a block's code located at x, y, z?

    Is it Engine.PositionToVoxelInfo(newVector3(x, y, z)).GetVoxel()
     
  41. RawLionWorkshop

    RawLionWorkshop

    Joined:
    Jan 29, 2014
    Posts:
    206
    Yes, your line is correct, assuming that x,y,z are world coordinates.

    Engine.PositionToVoxelInfo returns a VoxelInfo which references the specific voxel at that world position. You can then use GetVoxel and SetVoxel on that VoxelInfo to access and modify the voxel data directly.

    To modify the voxel data you can also use Voxel.PlaceBlock, Voxel.DestroyBlock or Voxel.ChangeBlock, which will trigger block events (OnBlockPlace, etc) and also send the change to other players in multiplayer (if enabled). VoxelInfo.SetVoxel bypasses all that and simply changes the data directly (and optionally triggers a mesh update).
     
  42. Windexglow2

    Windexglow2

    Joined:
    Sep 23, 2012
    Posts:
    90
    I'm about to send an email, but I purchased this over the asset store and have been unable to download (connection is extremely slow, getting 5008ms timeout errors with d/l). I am on a deployment and this is the best I'll probably get.

    Is there any way we could work out having the package sent to my email?
     
  43. Riwer

    Riwer

    Joined:
    Jan 19, 2014
    Posts:
    23
    Hi maap!

    I bought your plugin and I have a question.

    What's the correct way to spawn custom prefabs to a specific world position?

    I need to check adjacent voxels to check if is there enough space to spawn my prefab or not. But the scripting reference talk about: ushort GetAdjacentVoxel () and Voxel GetAdjacentVoxelType (), but isnt working for me :(

    I only want spawn trees and other objects arround the world...
     
  44. RawLionWorkshop

    RawLionWorkshop

    Joined:
    Jan 29, 2014
    Posts:
    206
    GetAdjacentVoxel is used only for VoxelRaycasts. It's for storing one voxel adjacent to the voxel hit by the raycast, so most likely not useful for you.

    If you want to check an adjacent voxel, you could simply use a position offset in Engine.PositionToVoxelInfo. For example, to find the voxel to the right of (0, 0, 0) world position, you can use:

    VoxelInfo adjacentVoxel = Engine.PositionToVoxelInfo (1, 0, 0);

    That's of course assuming that your voxels are the default size (1 world unit per voxel).
     
  45. Riwer

    Riwer

    Joined:
    Jan 19, 2014
    Posts:
    23
    Thanks maap! but I have another question.

    If I try in the GenerateVoxelData function, my fps drop to 3 and crash.

    Where or when I should do the voxel check? I need to analize all chunks after the generation?
     
  46. RawLionWorkshop

    RawLionWorkshop

    Joined:
    Jan 29, 2014
    Posts:
    206
    So you want to spawn custom prefabs for each chunk, right? If so, you can either wait until all chunks are done spawning ( ChunkManager.SpawningChunks == false ) and then analyze each existing chunk individually from some outside script, or you can do it locally for each chunk like you've tried, but in this case it would make the most sense to do it after the mesh is generated, so you could probably stick it at the end of the Chunk.RebuildMesh function.

    However, I'm guessing that the problem here is that you're calling your function a lot, and the Engine.PositionToVoxelIndex function is actually relatively slow. It wouldn't be a problem if you're only doing it a few hundred times per frame, but if you're trying to check every voxel in every chunk, that will cause huge performance issues.

    One way around that would be to just check the voxels directly by their index. Engine.PositionToVoxelIndex is slow because it needs to find the chunk object, but if you already have a reference to the chunk, then you can just do Chunk.GetVoxel(x,y,z), and apply your offsets there to find adjacent voxels.

    (Actually, in this case you can even do, for example, GetVoxel ( GetAdjacentIndex (5,5,5, Direction.Right) ) to find a voxel to the right of 5,5,5.)

    I'm not really sure if that's the answer you were looking for since I don't know the details of your code, in the previous post I assumed you needed to find voxels adjacent to some specific world position, but if you're actually analyzing each chunk's voxels locally then world position checks shouldn't be necessary. Let me know if you need more help.
     
  47. xNaXDy

    xNaXDy

    Joined:
    Apr 2, 2013
    Posts:
    6
    Hey there, looks like a really great engine you've got there.

    Only two questions though:

    Could you provide a bit more documentation on how to modify the Terrain editing? I'm looking forward to creating biomes, caves and decorations (patterns on the surface) and would like to know how hard/easy it is to implement with your engine. I don't want to buy anything that just turns out to be useless, you know?

    Also some documentation on how to set up a multiplayer environment would be nice!

    Many thanks in advance!
     
    Last edited: Aug 21, 2014
  48. RawLionWorkshop

    RawLionWorkshop

    Joined:
    Jan 29, 2014
    Posts:
    206
    Unfortunately, for modyfing the terrain generation, you'll need to write your own algorithm, or heavily edit the example one. Uniblocks doesn't come with any advanced terrain generation system, and the simple terrain generator is included only as an example, not a core feature. As such, the documentation doesn't actually cover the specifics of procedural terrain generation, since it's outside the scope of this asset and is far too big of a topic to be covered in a simple user manual anyway.

    However, there should be plenty of information on procedural generation available on the internet. The basic information on how to integrate a custom terrain generation algorithm into Uniblocks (accessing voxels, getting the seed, etc) is included in the documentation.

    The documentation also covers multiplayer in detail. Please let me know if you find anything lacking or unclear.
     
  49. xNaXDy

    xNaXDy

    Joined:
    Apr 2, 2013
    Posts:
    6
    Thanks for the quick reply.

    I couldn't find much multiplayer-related content in the documentation you uploaded. Is there another documentation that comes with the product?
     
  50. RawLionWorkshop

    RawLionWorkshop

    Joined:
    Jan 29, 2014
    Posts:
    206
    The first post links to the latest version of the documentation. There are sections detailing the multiplayer features in both the user manual and the scripting reference. It should cover the basics of setting up a multiplayer environment, but again, if you feel there is anything specific missing from it, please let me know.