So I am trying to create a little voxel editor. The player will be able to place a base cube, and then place other cubes on the base cube’s edges. Here is a screenshot of what I have so far: Imgur: The magic of the Internet
The way I’m doing this is by using a raycast, finding the point where it hits the base cube, and then placing the new cube there. In the screenshot you can see that there is a “target cube” that shows where the next cube will be placed.
The issue I ran into is that because the point where the raycast hits the base cube is right on the surface of the cube, the child cubes are placed right there and consequently end up half inside the base cube. I don’t want the cubes to be placed in such a way where they are overlapping with the base cube, I want the new cubes to be completely outside the base cube so they are sitting on the edge. I want it like this so that I can attach all the rigid bodies without any issues. I just can’t really think of a way to do this.
The only way I can think of solving this would be to check which side the target cube (or target position) is on, relative to the base cube, and move the new cubes accordingly. So if the target cube was on the left side of the base cube is would move the target cube left by 0.5 in order to account for it being half inside the base cube.
Does anyone have any other ideas? Any help is appreciated:)
I did something like this; with snap points etc…
However, I ran into this problem. My fix was making the target block always in front of me, that way, I can get any snap point I want.