Make Minecraft in Unity 3D Tutorial - 01 - The First Voxel

b3agz · 378K views · 2018 · 35:49

Open on YouTube

Game programming & enginesIndie game developmentComputer graphics & renderingtutorial

Why Stack Overflow recommends it

Stack Overflow users link it when asking about or answering Unity voxel and Minecraft-clone problems, especially chunk mesh generation and UV mapping issues that come from following this tutorial.

Recommended by 3 people across 3 different months, 2019 to 2020.

What it is

The first episode of b3agz's Unity 3D series on building a Minecraft-style voxel game in C#. It walks through creating a single voxel (block) mesh from vertices, triangles and UVs, at a deliberately beginner-friendly pace with source files on GitHub.

What people said

Recommends Theodor349 · 2019-08 · Stack Overflow · on “How to map UVs to Cube without small offset”

I am currently making a clone of Minecraft. When I map UV coordinates to a cube there seems to be a small offset. (The small white lines) [LINK] [LINK] [LINK] [LINK] [LINK] It looks to me like the glass texture is seen on the right side on the grass block. The code which generates the UVs is: public static readonly int TextureAtlasBlockWidth = 16; public static float NormalizedTextureWidth = 1f / (float)TextureAtlasBlockWidth; private void AddTexture(int atlasIndex) // atlasIndex is the index of the texture (Stone=0) { float y = atlasIndex / TextureAtlasBlockWidth; float x = atlasIndex - (y * TextureAtlasBlockWidth); x *= NormalizedTextureWidth; y *= NormalizedTextureWidth; y = 1f - y - Norm

Recommends Coder · 2020-04 · Stack Overflow · on “Trying to make Minecraft(following tutorial) code not working”

Here is my Chunk.cs code: using System.Collections; using System.Collections.Generic; using UnityEngine; public class Chunk : MonoBehaviour { public MeshRenderer meshRenderer; public MeshFilter meshFilter; void Start() { int vertexIndex = 0; List<Vector3> vertices = new List<Vector3>(); List<int> triangles = new List<int>(); List<Vector2> uvs = new List<Vector2>(); for(int i = 0; i < 6; i++) { int triangleIndex = VoxelData.voxelTris[0, 1]; vertices.Add(VoxelData.voxelVerts [triangleIndex]); triangles.Add(vertexIndex); uvs.Add(Vector2.zero); vertexIndex++; } Mesh mesh = new Mesh(); mesh.vertices = vertices.ToArray(); mesh.triangles = triangles.ToArray(); mesh.uv = uvs.ToArray(); mesh.Recalcul

Recommends herisson · 2020-05 · Stack Overflow · on “Is there a way to recreate the shift system from Minecraft in unity using c#”

Change speed: Detect that the shift key is pressed, if pressed change the value of your speed variable, i would use a multiplier: if (Input.GetKeyDown("LeftShift")) sneak = 0.5f; else sneak = 1.0f; speed = baseSpeed * sneak; Detect edge: Use a downward raycast from your player when shift is pressed. ( [LINK] ). Set maxDistance to be rather short, if you have ground under your feet it will return true, you do nothing. If there is nothing near under your feet, it will return false. The tricky thing here is that you can't just set the speed of your character to 0 because you would be permablocked. To solve this you will probably need multiple raycasts and make them work together to detect the o