Hertzole / HertzVox

A Unity voxel framework that is built for Unity and flexibility
MIT License
7 stars 5 forks source link

Tutorial #1

Open WireWolf opened 6 years ago

WireWolf commented 6 years ago

can you create a tutorial on how to implement HertzVox. For example how to create your own map, adding your own blocks, and non cube blocks such as stairs, ramps, and doors. Thank you for sharing your work, and any feedback would be greatly appreciated.

Hertzole commented 6 years ago

Hi!

First of all, thanks for your interest in HertzVox!

I, unfortunately, don't really have time to make a full tutorial but I'll try to help you as best I can!

Implementation can vary a bit depending on what you want to do. But usually, you just need to import it and start from there. What are you looking for when you say "create your own map"? To create new blocks, (at least with pre-made blocks like the one included with HertzVox, you right click in your project view - HertzVox - Cube Block and then you can add it to a block collection (which can be created pretty much the same) and then you can use it in code. Adding non-cube blocks is possible, but requires code and knowledge of creating meshes in code. It's also been a while since I last touched this but I think it goes something like this to create a new non-cube block: (based on how the cube block was made)

  1. Create a new class that extends from BlockController.
  2. Override the AddBlockData function to build faces depending on neighbor blocks. (like hiding faces if a block is right next to it)
  3. Create a new Builder for your custom block (see BlockBuilder for reference).
  4. Create a new Block Object. This is your scriptable object you can use in code and editor. Your new scriptable object should extend from BlockObject and then you need to override Controller() and make sure the controller returned points to your new class.

It's not the easiest task, but it can be done. You can even add some logic to your blocks, although not 100% supported. I also do realize this is a very unfriendly way of creating custom shapes and such, and I do have an easier way in mind that would allow you to use editor tools to create blocks. Unfortunately, I haven't had the time to do anything with this project until now, but I'm also researching how to do something like this but with the new Job system in Unity 2018. So I will probably implement a new way to create blocks later down the line.

WireWolf commented 6 years ago

Thanks a lot for your quick response, I am trying to create a game similar to 7 days to die. When I said custom map I meant I want to create an island manually (not procedurally) where the player can dig, build, etc. My programming knowledge is fairly basic but I will try to figure it out. If you have time make a video tutorial in the future that would be great. I plan on implementing marching cubes, if you have any advice on that. Thanks a lot for your advice and any more would be welcome. I am using unity 2018.1 by the way.

WireWolf commented 6 years ago

Would it be possible to integrate marching cubes into this.

Hertzole commented 6 years ago

Hi!

Sorry for the delayed response. Real life and work got in the way.

For the map you mentioned, there's no direct support for it, but it would be possible to build a map at runtime, save it, and then load it in in your actual game scene. And regarding marching cubes, I don't support it in HertzVox, nor do I intend to in the close future. I did look into it before but I didn't get anything out of it, so, unfortunately, I can't help you with that.

Good luck!

WireWolf commented 6 years ago

Ok thanks