I have created a game called Minecraft: dollar store edition (PlayCanvas 3D HTML5 Game Engine),
And I need a block placing system. The one I have right now is full of glitches, and the blocks don’t line up. Thanks in advance!
Hi @RumaiIndustries,
You need to spawn each block on a grid, calculate the final position on the cell.
Something like this:
const gridSize = new pc.Vec3(1,1,1);
const finalPosX = Math.floor(pos.x / gridSize.x) * gridSize.x;
const finalPosY = Math.floor(pos.x / gridSize.y) * gridSize.y;
const finalPosZ = Math.floor(pos.x / gridSize.z) * gridSize.z;
const finalPos = new pc.Vec3(finalPosX, finalPosY, finalPosZ);
3 Likes