Free Package - but I can't offer much support for this


Block World Inspector

Block System is a Minecraft-like framework, where you can place and remove blocks.

You can download Block System (Right Click and Save Link as) Here v2020.3.2f1

Please note: This is not a full game, only the Block system, You will need to add all the Blocks you wish for your game, (placeholder examples are shown below) and also the HUD, Inventory, and what else you need for your game.

Overview

The Block system is a game world where the environment is all created from blocks. Allowing the player to place and remove the blocks as they wish.

This package handles all of the below.

  • Adding and removing blocks
  • Blocks are grouped into 10x10x10 Block groups to optimize the creations of the mesh
  • Removing blocks using a decay effect overlaid on the mesh - so it takes few hits before getting removed.
  • When removed the block will appear as a pick-up of the block type
  • Can use meshes for object blocks (Meshes are backed into the main mesh for speed)
  • Interactive objects (like Doors) are placed in the map (not baked into the main mesh)
  • Each Block has a direction, so blocks can face the way they were placed
  • Loading and saving of blocks (Persistance), Where many different worlds can be created
  • The Block system has the framework for more than one player in the system.
  • Simple Hot bar - using the number keys will select on item on the hud.

Please note - this package is currenly is supporting
  • Lighing - but could do
  • Very large worlds - but could do, It just takes a long time to create the world.
  • Inventory. (Only a hot bar is added)
  • Player Tools/Weapons (but we have a place holder enum for tools)
  • Animals
  • Villages
  • Monsters
  • Chests
  • Crafting
  • Sound Effects

And you will need to programm in c# to make the most of this package.

Download preview

You can download the windows build of this project to get a feel of what it can do. please download and try before buying.

Keys: WASD to move and 1,2,3,4,5,6,7,8,9,0 to select item to use.

Use right click and selete 'Save Link As' Download

Creating worlds

Using the provide demo scene, "TestMap" We can take a look how things are set-up Everything runs off the "BlocksWorld_pf" prefab

Block World Inspector
  • World Name: Save name of the save game data.
  • World SIze: The x,y, z of the size of the world. (Large worlds will take a while to generate)
  • Cliffs Per Block: How many cliffs to randomly add per block
  • Hills Per Block: How many hills to randomly add per block
  • Tree Type A Per Block: How many Tree type A to randomly add per block
  • Tree Type B Per Block: How many Tree type A to randomly add per block
  • Set Load Map:Use the world name as the map to load for this scene.
  • Create new World Will create a new world using the setting above
  • Delete World Save Game DataRemove any save data for this 'World Name'
  • Add Tree Type A Add a tree-style A to the world
  • Add Tree Type B Add a tree-style B to the world
  • Drop Rocks Randomly drop a rock in the world
Note: World Name Needs to be unique.

Add new block types

To add a new block into the system just create a new block in the Blocks folder

Code Block Folder
Code Example Block
  • The new block will need to inherit BlockDetailsBase
  • BlockType: Should be a unique name for the block.
  • BlockCategory: Need to be the Category for the block
  • BlockStrength: The strength of the block
  • IdealTool: Best tool type to use on the block
  • UVCube: The matrix for the UV sides
  • HUDSprintName: is the name of the image to show on the hud

UVs

The UV cube holds 6 sets of UVs - one for each side of the cube. You can set each UV set as you need as I have done for Bark.
Game Bark Code In Game Bark.png

The UVs setting is just the coordinates from the textures
UVs blocks

Add new block mesh types like a fence

Not all Blocks have to be cubes, things like Chests are predefined meshes.
In Game Chest
Code In Game Chest
  • MeshObjectName: The name of the mesh to use
  • UVCube: Can be null as we don't need it here
  • BlockView: This is to let the system know where or not to hide the ploy below.
  • CanPlaceBlockOnTop: Can we place a block on to of this block.
And sometimes you need the meshes to be dynamic and change based on what is around them. Like fences. Where you will want to have a corner fence mesh.
Dynamic Meshes.png
Code In Game Fences
  • MetricLogic: The class where any extra logic can be added.
    This is called when the mesh is created so it will know what extra logic to apply. Allowing for other meshes to be used.

Add new interactive objects like doors

Interactive objects can't be backed into the mesh so we just add them like other GameObjects.
InGame-Doors.png
Code In Game Door
  • PreFab: Name of the prefab to add
    Prefab needs to be in a Resources folder
  • BackInMesh: Should be false
  • BlockView: Should be false
The prefab should have a class that uses the interface 'IObjectActions' and also the collision name should start with the name 'Interactive-'. That will allow the user to click on the object.

Show Working Door

Player Code

The player used in the demo scene is nearly the same as the Standard 1st perons controller. If you have your own 1st person controller just add 'BlockMiner' script to your player.
player .png
The only field here is the Player Index This is used when you need to have more then one player in the game. Where the index is just the player number.

Player indexing is handle by using PlayerHub.Instance.GetPlayer(PlayerIndex) to get the PlayerDetails class. That holds all the player details

For the player details it has

  • PlayerInventory: Where the hot bar is stored
  • PlayerActions: What action can the player do

Player actions are taken from the enum PlayerModes
  • Normal: Normal mode
  • Creative: Object don't count down then they are used
  • Adventure: Can't add or remove blocks
I've added easy assessors like
  • PlayerHub.Instance.GetPlayerActions(PlayerIndex).CanPlaceBlocks
  • PlayerHub.Instance.GetPlayerActions(PlayerIndex).CanRemoveBlocks
  • PlayerHub.Instance.GetPlayerActions(PlayerIndex).CountDownItemsWhenUsed
  • PlayerHub.Instance.GetPlayerActions(PlayerIndex).OneHitRemoveBlock
That all just return a bool.

Project Structure

Project structure Everything is within the ewolf Folder
  • Model\Resources:Meshes of objects to bake in to the mesh
  • Textuers\Icons\Resources:Are the images of the blocks for the HUD
  • Prefabs\Objects\Resources:All the interactive object prefabs
  • Scenes:Demo scenes
  • Scripts:All the scritps needed for the Block System

Creating Hud Icons

To help with updating the hud Icons when you change or add new blocks I've created the scene 'CreateBlockIconImages'

Before you run the scene just create a folder 'BlockImages' one level above the Unity project folder. And then just play the scene and it will run through all the Block Enums and taking an image of each one.

So you can take this image and just cut it down to how you want the HUD icon to look. And just place your new Hud Icon in the folder 'eWolf\BlockSystem\Art\Textures\Icons\Resources'

(Any 'Resources' folder will do)


Demo Game

I've set up a demo game scenes (Meun and world)

Run the 'Menu' scene and you will see some basic world creation options to play with.
create world.png
  • Load Will try and load any pre saved world with that name.
  • Create Will create a preview for you to look over.
  • Test World will jump to the world Scene where you can walk around the world.

Show Create world

Show Test world

More Help

I've collected some common questions Here

Free Package - but I can't offer much support for this..

You can download Block System (Right Click and Save Link as) Here v2020.3.2f1

Should you still need help you can email me at Wolf@electricwolf.co.uk

It would be nice to know if you are able to use this project.