Hey guys. Right now I’m trying my hand at a small voxel engine, but unfortunately I’ve run into an issue. For some reason I can’t seem to be able to convert world coords into chunk coords. My current code for getting the chunk from the world coords is :
public Chunk GetChunkByWorldPos(Vector3 pos)
{
Vector3 chunkPos = new Vector3((int)(pos.x / World.staticChunkSize), (int)(pos.y / World.staticChunkSize), (int)(pos.z / World.staticChunkSize));
return GetChunkByPos(chunkPos);
}
To me it seems good but when I test it I get this.
On the 3rd line down is where I show the chunks. The left is a raycast showing what chunk it hits and on the right is the chunk the code gets back. Any ideas on where I’m going wrong? And if you need to see anymore code just let me know.