1
$\begingroup$

I have the board made, and some rudimentary pieces. I need to figure out how to use the game engine to move the pieces around. I do not want to write script yet that actually plays the game, because it needs a lot of play testing to work out any issues. I've watched several game engine tutorials, but none I find relate specifically to moving pieces around on a 3D object like this. Any ideas about where I can look for this type of info? I will continue to work on better renditions of the board and pieces while I'm learning the rest of what I need to know.

work in progress

$\endgroup$
  • $\begingroup$ It should be possible to do this. I don't know how to move them around spherically (there is definitely a way though), but, you could have the sphere initially a flat plane and then apply some sort of modifier to make it into a sphere. $\endgroup$ – 10 Replies Jan 8 '17 at 0:55
1
$\begingroup$

Video of end solution:
https://youtu.be/2XNgRXUhVQI

Blend at end of whole post:
https://drive.google.com/open?id=0B27awtGNGuMPd1Y2QzVXSEt6aUE

Basic Setup

1) Create a red piece by creating a cube and scaling it on the Z axis. Give it a material with a red diffuse color, 'object color' enabled and give it the game property 'PIECE' (value does not matter) enter image description here

2) Create a blue piece the same as before but with a blue diffuse color (If you already have pieces, make sure 'object color' is enabled and they have the game property 'PIECE'

3) Create a tile by creating a plane, giving it the game property 'TILE', and enabling 'object color. Duplicate the tile a couple of times, feel free to use random angles: enter image description here

4) Create a new text datablock with the name 'move_to_tile.py', and past into it the script from here: http://pastebin.com/tVgmqCkJ

Create an empty with the logic bricks:
Always -> Python

The always sensors should be in pulse mode (green circle on left) The python controller should be in module mode, and should have the text 'move_to_tile.init' (middle green circle) enter image description here

Put it in blender game mode, hit 'play' and you should be able to move the pieces around. If the pieces are all grey, make sure you are in GLSL 'textured' mode. You may need to add a light source.

Note that you can duplicate pieces and tiles as you will. Do whatever you like.

Creating a Spherical Board

Blend at end of this section (same as first link)
https://drive.google.com/open?id=0B27awtGNGuMPd1Y2QzVXSEt6aUE

We don't want to have to place planes for all the faces in the platonic solid you have above. That would take far too long. Thankfully blender has some neat tools.

1) Add your base shape. Give it the tile material (object color enabled) and the game property 'TILE'

2) In edit mode, select all faces and run 'edge split' (press space then type 'edge split'). This separates all the faces. If you have non-triangular faces, then only select the edges of the tiles. enter image description here

3) Now seperate all the faces into separate objects using 'P' and 'by loose parts.' enter image description here

4) The script places objects at the tile origin, so move it using the set origin to geometry button with all the tiles selected: enter image description here

Now you should be able to move the pieces all over the spherical board.

$\endgroup$
  • $\begingroup$ Comments are not for extended discussion, all the comments have been moved to a chat room. $\endgroup$ – David Jan 16 '17 at 22:18
1
$\begingroup$

Represent the board using a more abstract notation. Essentially, you need a way to store co-ordinates in 3D space.

One way would be to place empties at all possible piece locations. Then you can snap to them. This is quite a limited approach. A better solution is to use a mathematical representation. For example, a sphere is very easily notated in ... spherical co-ordinates (two angles and a radius). Thus to snap a piece to a location is just a coordinate conversion issue. An easy way to think about this if you don't have experience with spherical coordinate systems is if you have a single piece at the top of the board, parent it to an empty in the middle of the board, and then rotate the empty. The piece will follow the surface of the sphere.

You will need python for this for the reasons pointed out by Quacksilber. I can think of ways to do it using animations and logic bricks but it will be a huge huge huge effort that will be very tedious.

I am quite interested in your game. Looks a bit like chess? Programming chess is never easy at the best of times (aka a flat board)

$\endgroup$
  • $\begingroup$ I used coordinates to build the sphere. Can you explain what you mean by an empty? @sdfgeoff $\endgroup$ – quazipseudo Jan 12 '17 at 8:09
  • $\begingroup$ If you're using coordinates to build the sphere then your job is mostly done. You just have to build an interface that allows you to select a piece and move it to a specified location. This sounds like a fun mini-project. I'll just have a quick go at this. $\endgroup$ – sdfgeoff Jan 12 '17 at 23:15
0
$\begingroup$

Why not make one object for one tile?

When you know the tile, you know where to place the 3d model of the stone.

$\endgroup$
-2
$\begingroup$

I think, the easiest way would be using a flat baord, I guess it's nearly impossible to do the 3D-board version without python scripts. The only way I see to move the figures on a 3D-board is by animating every figure, placing it manually on the fields, one "frame" per position. But that would cause a total mess if you want to move them all around - allready for a single figure you would have to connect one logic brick per field on your board. So let's say there 50 fields, multiply with let's say 40 figures makes around 2000 logic bricks you'd need to connect by hand. (If not using scripts)

By using a flat baord: You probably might search for videos on "point and click", so by clicking on a field, the selected figure would go to it. Then you should also look for the mouse-sensor option "mouse over", which tells you, whether the cursor is placed over an object (wich you can specificate by using game properties). Firstival, you should declare game properties like "turn" and "selected figures".

Please tell me, if you consider using a flat board, if not I could tell you more about the action-animation way and if using a flat board feel free to ask about the property stuff! :)

$\endgroup$
  • $\begingroup$ I might do a flat board as a learning exercise, but the end product has to be on the geoboard. I'll consider your suggestions, and I'll let you know which way I go. Just to be clear, I want to write script, (not that I know how,) I just don't want to write script as detailed as a full chess engine. Only to move the pieces around manually. @Quacksilber $\endgroup$ – quazipseudo Jan 7 '17 at 21:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.