I am trying to make a grid placement system, but I am not sure how I could do this. Could anybody help me? (I am not looking for code, but on HOW I could write the code for this system myself)
I have looked at the article, and it helped a lot. But I have one issue though, it is that I am trying to make a placement system similar to the Roblox Bedwars Game(game link here), the article helped me understand a lot more about grid systems, but how would I be able to make it where you could place blocks anywhere across the map and over the void or where nothing is under the block being placed? (Sorry if the article said anything about it and I missed it)
If all of the blocks are the same size, you can try using raycasts. Cast a ray from the player’s camera to the player’s cursor position (Mouse.Hit); gather information from the RaycastResult and use the surface normal to offset the block by exactly one voxel.
To simplify:
You use raycast to identify the block the player is looking at.
You use the surface normal to identify which side of the block the player is looking at.
Using the surface normal (which is a Vector3), you can calculate the position of the placed block.
Oh okay thanks, that helps a lot. I do have all the blocks at the same size, but if they were in a model, would it still work? (Sorry, I am still pretty new to coding)
You want to make sure that the raycast picks up the voxel itself and not some of the individual parts in the model. For detailed blocks like those, you can try encasing them in an invisible cube which acts like the voxel.