Fehniix / UnityMinecraft

A C# Unity Minecraft clone under development for the University of Calabria, Virtual Reality course.
4 stars 2 forks source link

My version of yours #1

Open dcmrobin opened 1 year ago

dcmrobin commented 1 year ago

Hi! I discovered your Minecraft clone a long time ago and downloaded it. I've been working on my version ever since, and was wondering if you could check it out! https://github.com/dcmrobin/UnityMinecraft

dcmrobin commented 1 year ago

The second one, meaning the one I suggested? Yeah, I'll try... I've just got to figure out a way of detecting (from the log.cs script) what face the log is being placed on.

Edit: I've made a way for the buildmeshfaces method to get the placed block: image Now I just need to detect which face the block is being placed on

dcmrobin commented 1 year ago

Do you have any idea how to detect which block the player is looking at? If I got that, then I might be able to get the face of that block when a block is placed, and then put that into the if statement in the picture above.

Fehniix commented 1 year ago

Hmm. The only way that comes to mind right now is by taking advantage of the rotation angle of the camera; if you determine the player is looking down, you're placing a block on top of another one - if you're looking up, bottom face, and, for the remaining faces, you could determine what cardinal direction the player's looking towards: North, South, East or West.

dcmrobin commented 1 year ago

that's a good idea... yeah now that I think of it, that would work!

dcmrobin commented 1 year ago

I have an idea for the ambient lighting in caves problem: when you get to a certain y-level, the skybox changes, or all ambient lighting gets taken away. another way is to check if there's only air above the player... but that wouldn't work as you going under a tree would get rid of ambient lighting, and also you could light up an entire cave by just standing under a hole in the roof of it. let me know if you have any ideas as well!

dcmrobin commented 1 year ago

Oh, I've got it! You very helpfully implemented a variable called "Baselandheight" or something like that to help place trees on the ground. If I had the ambient lighting go away as soon as the player goes below that value!

dcmrobin commented 1 year ago

Sadly I found that the baslineLandHeight var is only assigned and accessible in the function of terraingenerator.cs that runs through the blocks and makes them grass, rock, etc. that means it can only be used when the chunk is generated or regenerated.

Fehniix commented 1 year ago

Hey!

Correct. It is only used to decide where to start placing trees, if I remember correctly.

Three good ways to determine if a player is inside a cave or not could be:

  1. Player moves, you scan the surroundings to detect a cave-like structure, but this is extremely power hungry and potentially very inefficient,
  2. There might be a way to bake into the Perlin noise generation algorithm positional triggers for tunnel-like cave entrances, but this wouldn't take in consideration terrain modification – needs to be handled separately,
  3. When generating terrain, you could scan for cave-like structures and map their areas: you may be able to include this information within the chunk, I'm thinking about a set of 3D bounds that delimit a cave region.

I'll take a look at how Minecraft actually does this, I'm really curious. Hopefully this helps someway!

dcmrobin commented 1 year ago

Thanks a lot for the response and those are some great replies! I got the idea for checking if below ground from a Minecraft video, that, when the player dug underground the skybox changed color, and then when the player got back above ground the skybox was light again.

I could also (as a temporary fix) I could have the ambient light go away once the player reaches a low y-value. (one that couldn't be reached above ground)