Hi, i am trying to make an electrical system in Blender GE which transmits via cubes. Each cube becomes powered on collision, but the blocks need to be placed according to a grid which is determined by the Ray of a camera. The most simple way to me would be to create planes with no collision every 1 blender unit which then when activated by a ray add the cube object, but this uses way too much resources for what it does. Is there a non-resource-intensive way of doing this? Thanks 
I’d like to help, but I am having trouble picturing what you’re trying to achieve. Could you clarify?
Sure. Create an internal model via Python.
For a grid, lists are sufficient. Also dicts can help. Or you build an own graph.
Then you can perform all processing on this internal model. You do not even need the BGE to do that.
Then use the BGE as presentation layer of the internal model. The 3D models in the BGE are the (visual) representation model.
If the internal model changes (e.g. on update) you update the representation model as well.
You can pass input from the representation model to the internal model (e.g. the user clicked a 3D model).
The internal model processes this input performs it’s changes and transfers the changes to the representation model.
In other words the internal model leads!
I hope this is somehow understandable.
Example: A chess engine does not care how the chessboard looks like. It runs on a grid with symbols as figures. It processes the turns only.
Moving figures dealing with the user input is not performed by the chess engine but a separate presentation engine (known as GUI ;))
I am basically looking for a “Minecraft” type block placing system (I saw some videos of Minecraft on YouTube). Just the placing system, not voxels or any of that stuff. I think that what you are telling me do do, Monster, is a bit complicated for what I am looking for ;). I have only started Python and I am still going through basics
If I actually knew how to do that stuff, I would… But for now, I need something somewhat simpler. I had an idea of having only lines and vertices (so the GPU does little work) and then add objects at the vertices, but I need something to react to Ray sensors (a face). Perhaps I could use something like a bullet hole script, but then it auto-aligns itself to the center of the cube it is being spawned on?
Thanks
I think you are being scared off by Monsters jargon and its a shame because he is onto something. By co-incidence. what he is talking about is something I asked about in one of my recent posts. It is not that complicated.
To break it down into steps:
-
1) Look here and here, this gives you a simple way of having an underlying program that can be accessed by all of the python controllers in your game.
-
2) This underlying program stores all of the data, (for example in an array of boolean,) and does any processing.
-
3) When a controller is activated by a player action, you access the underlying program and update the GUI
Monsters example of a chess engine and a chess GUI, was very accurate, but a very bad example. The chess engine is completely outside of the BGE, with a single access point. It also involves some fairly advanced programming techniques. In the way I have outlined it, your underlying program is incorporated into the BGE with multiple access points through the python controllers. In practice, I do not think it should be very much different from writing and debugging a script.
I don’t know if one would even need to create a model with some clever programming.
You can always try to use a script to make the object look as if it is being placed as if on a grid, even though in reality there is no grid structure created by empty objects or otherwise.
Take this piece of code for using a ray position to get a position where, when the final variable is used to define the position of the new object, it looks as if it’s snapped to a grid (from one of my projects, it might need some changes as for one thing it assumes you at least have a plane to act as the base).
if not rayDownOb == None:
rayZ = rayDownOb.worldPosition[2]+2 #making sure the object is above the base
#The following snaps an object to an imaginary grid on the Z-axis, in your case you may need to
#repeat the operations for the X and Y axis.
div2 = abs(rayZ % 2) #This uses Python's remainder operator, very useful in this case as it
#performs a division and gives you what is left
if not div2 == 0:
rayInt = int(rayZ+div2) #add the remainder to the initial position, in this example it ensures
#that any Z position the object ends up in is divisible by two, which in turn can be seen as
#emulating a grid on the Z-axis with each cell two Blender units in height.
else:
rayInt = int(rayZ)
@Blendenzo: This is amazing! Especially since it is uses barely any system resources. Thanks 
No problem. Like I said, I actually just happened to have that laying around.
We will be releasing the zombie game we made with that system in the near future. The actual game is much more resource intensive, so I’m using some tricks to try and bring it down. (I think I will be erasing all zombies that are not visible, and just leaving their collision hulls to save on the extra armature deformation calculations. The game runs alright on my system with about 70 enemies right now, but I know it could be better. It is running much smoother since I scaled down some of the textures and compressed them in DDS format.)