So I’m making the game above, where tiles can be placed on the side of existing blocks. However, I’m having trouble detecting whether there something occupying the space before placing the block.
Each space is 64 x 64 x 64, so I basically don’t want to place two objects in the same space.
How do I…
How do I detect that the space is empty when placing? I’ve tried raycasting (I’m using raycasting to get the right position initially), but I can’t seem to figure out raycasting from what position to the empty space. What compounds the issue is that I’m placing the same objects that I’m trying to detect, so I can’t really use the usual detection methods.
What is the expected result
If space is empty: place tile/block.
If space is occupied: don’t
Okay so I figured out a system that works for me. It involves a structure of arrays that gets updated with the z-level and coordinates every time I place a tile, and then when I place a new tile, these are checked first to see if they are in the structure.
I actually had it set up this way before, but I was getting stuck with guide tiles getting placed over the actual tiles, so after I implemented the above approach, I was able to reimplement this with proper tile detection. Plus now the player can place at any angle.
In fact and i think you rectified that, we must read my sentence in inverse order.
My sentence should be
“In case of collision with invisible blocs, you can place real visible blocs”