create cube parent
Blitz3D Forums/Blitz3D Programming/create cube parent| 
 | ||
| Hi, I would like to know how to use the createcube() and make it a parent of other cubes. Im trying to make a cube game with sections made of cubes to make one big cube, something like the rubiks cube. Please Help... Thank You. | 
| 
 | ||
| You are probably best parenting multiple cubes to pivots as opposed to each other. | 
| 
 | ||
| I'd suggest by making the 'Big Cube' just a pivot, since it wont actually exist as a 3D object, but just to represent all of the little cubes as a whole Global ChildCubes[8] Global BigCube=CreatePivot() For n=0 to 7 ChildCubes[n]=CreateCube(BigCube) ---edit--- like Puki sugegsted 2 seconds efore me :P | 
| 
 | ||
| Oh, that's actually pretty easy if you know how. Just create your parent cube first, then create the other cubes as children. Like this: ;Create the first parent cube Global Cube1 = CreateCube() ;Now create the others & assign Cube1 as their parent Global Cube2 = CreateCube(Cube1) Global Cube3 = CreateCube(Cube1) ;... And so on. Repeat as needed. An alternate method is to use EntityParent(), like so: Global Cube1 = CreateCube() Global Cube2 = CreateCube() EntityParent Cube2,Cube1 Hope that helps! | 
| 
 | ||
| How do I rotate all the cubes together using the pivot just like the rubiks cube? this is what I have so far.. it only rotates that one cube.. Dim cubes(16) P_cube = CreatePivot() For i = 0 To 15 cubes(i)=CreateCube(P_cube) Next PositionEntity cubes(2),0,0,5 PositionEntity cubes(3),2.2,0,5 While Not KeyDown( 1 ) mx = MouseX() my = MouseY() RotateMesh cubes(1),mx,my,0 RenderWorld Flip Wend | 
| 
 | ||
| to rotate the whole lot as one, just rotate the pivot :) RotateEntity P_Cube,mx,my,0 | 
| 
 | ||
| Yes, and as Malice shows, be sure to use RotateEntity instead of RotateMesh! Else your mesh data gets deformed.. | 
| 
 | ||
| Yes, and as Malice shows, be sure to use RotateEntity instead of RotateMesh! Else your mesh data gets deformed.. I only put RotateEntity as I didnt expect RotateMesh to work on the Pivot lol. |