- Home /
How to texture blocks in a way similar to Minecraft?
So I'm new and really liking the engine. I'm currently just playing around with and trying new things. I'v been playing around making a map out of cubes for fun and it looks great but I want to find out how to texture them. I know about materials and how they basically work in unity but when I put a simple texture on a block I get the same thing on each side or reversed or otherwise.
My goal has to been to make the blocks sort of look like they do in minecraft. That being 4 of the 6 sides of the cube have the same part of the texture while the top (don't really care about the bottom) has a different part of the texture wrapped onto it. Such as a grass block I think?
Another way of asking this is if we think of a cube like a dice I want the top being side 1 to differ from sides 2-5. If a texture is a flat picture, how do I wrap it around my block in such a way that it covers it how I want it?
Any help would be great, in editor or scrips if I have to. I AM NOT MAKING MINECRAFT!!!! I am just using that as an example for how I want my blocks to look. No tile mapping or block behavior necessary. Thanks for hopefully understanding.
How are your cubes generated? How do you assign textures?
Answer these questions and also take a look at this thread:
http://forum.unity3d.com/threads/63149-After-playing-$$anonymous$$ecraft/page117
Yes I am using the primitive Cube game object and it sounds like UV mapping is what I was trying to figure out, I just didn't know the name of it. Will research more about UV mapping and try stuff out, just sounds more complex then I would have hoped. Any tips y'all wanna throw my way on how to easily UV map?
Also this isn't really a game yet, and its not $$anonymous$$e craft, just playing around with blocks on a map for now. I'd like to keep the number of cubes as low as possible, so I won't make a cube out of quads, but maybe I'll just put a quad on top with the texture I want there.
@getyour411 - I'd up vote you, but it won't let me :/ too much of a noob
What you actually want to do is click the check mark to mark an answer as 'correct'. This will do magical things.
If you are trying to do a voxel (cube-world) game, you must not use a 3d grid of primitive cube gameobjects. It's a waste of time even trying to do it that way- do more research to understand why and what the right way is.
Answer by getyour411 · May 17, 2014 at 11:53 PM
Google: UV map
Actually, I'd look at trying out Blender 3D. It's a free 3D application that runs on almost every platform. There are a few ways to generate a cube in Unity to do what you are looking for, but the effort will be wasted as it is much easier to make your models in a 3D application, UV map them there, and import them in to Unity (you'd be heading that direction anyway). I made the $$anonymous$$ecraft chicken for a student I was working with about a year ago, and now I can't help but add this pet to every character I make when running some tests!!!
Answer by JasonBricco · May 18, 2014 at 12:05 AM
Basically you don't texture the whole cube, you texture each face that makes up the cube separately. If your cubes are primitive cube Game Objects, then I don't (think) you can do it this way although I'm not sure. I don't do mine that way.
But you could maybe make a cube out of primitive quad objects and texture each of those (and parent them together). You would want that whole cube being a single mesh, though. There are assets for this...
In a Minecraft-like game, you generate your faces procedurally and assign the texture procedurally. You have a big tile sheet with all your textures. You use UV mapping to select a section of that tile sheet to be put on a specific face.
There's kind of a lot to it, it's hard to answer without knowing exactly how you're making your game.
Answer by Cherno · May 22, 2014 at 03:15 AM
Here is a complete sample code for a Minecraft-like chunk mesh generation including adding and deleting blocks. I have used it as a base for my game myself and customized it to my own needs. It's easy to understand so I suggest you take a look. There are many other similar scripts around.
Your answer
Follow this Question
Related Questions
Simplest way to have a damage decal or texture on cubes. 0 Answers
How do I make this?? 1 Answer
texture.width not returning actual image pixels 2 Answers
texture alpha with color constant 2 Answers