Evenly separated blocks

So to make a game like minecraft there would have to be a way to keep blocks evenly spaced. How would this be done? Yes I know coding is most likely involved. But I have a fairly decent idea of what the code would have to be. The owner (the placer block) would have to only be able to move 1 blender unit at a time. But what would I import and what would all the variables be? (sorry I am a bit new to coding)

Use array modifier click on constant offset on the array modifier. The first number slot under it change the number and then apply the modifier.If you are going to use properties put the property on the array cube.Go to edit mode.Then go to vertices menue.Then go to go to seperate menue.And then in that menue click on loose parts.That is how i do it.It would make a great tutorial as well.

You would import the bge.logic module, and the variables would be the object’s worldPosition variable. It’s not complex at all, but it depends on how you want to approach the object’s movement (i.e. you’d probably want to place new objects on a grid, rather than lock all objects to a grid every single game frame, or even frequently).

be aware that such game semm easy (and maybe here simply)
but require a engine specific, (in bge many cube waste the cpu quikly)
just to say

anyway if you want use as unit 1 meter (1 bu)
you can use the build-in “round()” (or also “int()”)

for example :

##########
import bge
own = bge.logic.getCurrentController().owner

x, y, z = own.worldPosition
own.worldPosition = round(x), round(y), round(z)
##########

Also, if you want to utilize a virtual grid that’s more than one Blender unit big then you can use the remainder ‘%’ operator in Python to help snap the object to divisions of 2, 4, or whatever size is needed.

Or you can multiply the object by an amount (the grid size), round it off, and then divide it by that same amount.

what about 99 blocks 66 blocks 4*4 etc, that just get textured and spwned in to fill the roll of many blocks? broken up /subdivided into more objects?

In Blender:

  • hold the <ctrl> key to snap to the current raster.

In the BGE:

  • You can ensure movement is always a multiply of 1BU and turns are always a multiply of 90°. (No Python required.)
  • Another method is to snap positions to a raster e.g. by truncating the decimal values (Python required)