Hi all,
I am after some thoughts on grid based movement (for a chess style game). If you look at the attachment I have a setup of 3X3 ray sensors area around a unit which checks the properties of the grid tiles. If the right conditions are met it will send a message to highlight the appropriate tiles so the player knows which tiles can be moved to.
This works fine, but it seems a bit messy and not that flexible (I’ll probably need a different array for each type of unit). I was wondering if anyone has any ideas of other ways this could be achieved?
Thanks,
Blenderage
Attachments

Simple solution
tileList = [[‘blue’,[0,0,0]],[‘blue’,[1,0,0]],[‘blue’,[0,1,0]],[‘blue’,[1,1,0]]]
If you set the tiles to be 1x1 blender units and name the like ‘tile_x_y’ where x is the x position and y is the y position you can use the location of the object you are checking to find tiles.
e.g.
object = obl['OBCube']
[x,y,z] = object.getPosition()
middle_tile = obl['OBtile_' + str(x) + '_' + str(y)]
above_tile = obl['OBtile_' + str(x) + '_' + str(y+1)]
below_tile = obl['OBtile_' + str(x) + '_' + str(y-1)]
right_tile = obl['OBtile_' + str(x+1) + '_' + str(y)]
left_tile = obl['OBtile_' + str(x-1) + '_' + str(y)]
You will have to be careful because if the object is on the edge then it won’t be able to find some tiles because they don’t exist.
Thanks for the help, I’ll check this out.