Continuing with the damn inventory system
I have chosen to use the TAB key to move between the different slots of the fast Inventory.
The background color of the selected item changes and the previewer of the brick to be put is updated according to the new selection.
I have also taken the opportunity to refactor the bricks that were in the scene. Until now they were literally put there, which should not be the case. The server is supposed to be in charge of spawning the bricks. And so I have.
Breaking blocks and types of blocks
Now that I have an inventory system (although not with all the characteristics that I had indicated at the beginning), I will surely choose to start adding color to the blocks, making them imply a different type as in minecraft. That is, that brown is dirt and costs less to remove than a metal one for example.
Reviewing how minecraft does it (Minecraft.gamepedia.com), they are based on giving each block a value called "hardness", which ranges from 0 to 100. And depending on this value and the tool that you carry in your hand, it takes more or less to chop the blocks.
Again I was lazy, so instead of using that same scale, I have created a hardness value for each brick, which is directly the number of seconds it takes to chop it by hand. If the game had tools, then it would deduct seconds.
I also wanted to add the breaking effect that minecraft does:
But it seems to me that it is not yet the time to do this considering the overall state.
Blocks can now have assigned textures. The thing is that in doing so, I happen to need an icon for each block instead of the generic ones I already had.
My first approach has been to get the generic image of the brick and put the corresponding paint on it. As you can see, it has been a fiasco.
It's time to generate an ingame render, which is quite a pain in the ass. So I've only done it with the first one.
Once i decide to put all brick models, I will make a small scene in which each item appears in the center and a screenshot is taken automatically. I will only have to see how to erase the background or if I can put a solid color and tell it that it is the alpha.
Revisiting the build system
After this I couldn't help but start building a little house and ............ it was terrible.
The pattern of 1 stud of space between each brick it's not done on purpose, it directly did not let me put anything there. It also seems that depending on how, it puts a lot of space between the stacked blocks, enough to make it look and feel bad: S
fckinghell time to head back to core, the build system.
I think the first problem is because the blocks occupy their space perfectly, so they touch each other and the system detects it as a collision.
Megazoom to visually show the problem.
- A trick would be to touch the collider of the blocks so that it is slightly smaller than the model.
- Another fix would be to make the preview scale smaller than the final model.
- And the correct way (I suppose) would be that when detecting a collision, check how much % of the surface is put inside the other block and discard those that enter less than 1%.
Obviously the correct way involves doing calculations and blah blah blah, so I'll do the second fix and keep my fingers crossed that it has no long-term consequences.
Hehehehehe. It's taking shape.
After doing this, I noticed that for glass I used a 2x2 brick which doesn't make any sense because you can see the brick interior. Looking for a window model on mecabricks.com (the place where I get models) I noticed something else that I liked even less.
As a model name, I have been putting the one that came out on the web, thinking that it was the standard:
However, for the windows this was the name:
And google did not return any results ... I kept researching and my conclusion is that when the name is numeric, it is correct. And when stuff like the one in the example comes out, I have to google another source like Bricklink.com in order to get the real id.
Surely you will ask yourself, "And what does it matter if it is one number or another if it is not seen in game?"
In a way, yes, it doesn't matter. Buuuuuut, if I keep the correct identifiers, it will let us do things like:
- Virtually assemble Lego sets: You only need the ids of the bricks (which websites such as bricklink has for each set), the quantity and time to build!
- Export M.O.Cs ("My Own Creation"). Creations that users make online and that they sell you instructions on how to assemble them. Here you can see what I'm talking about Rebrickable.com
And going back to the image:
You may have noticed that I did not close/connect the top of the entrance. The reason is simple: in Minecraft you can put blocks to the left or right of others, which magically hold and remain consistent. But in Lego? ... I can't enable this magic because it would break all stud logic.
I just need to improve the shitty brick rotation system that i made before so i can do it properly.