track pieces
Blitz3D Forums/Blitz3D Beginners Area/track pieces
| ||
I am working on a 3d racing game in which players can create there on tracks in the game. I am currently working on code that creates cubes, and these cubes will eventually be textured and used as the track pieces. Here is my code. ;;;;;;;;; ;;;;;;;;;; For t= 1 to 10 track#=track#+1 track#=createcube() next positionentiy track#,0,1,10 ;;;;;;; ;;;;;;; How do code the for t=1 to 10 so that each track piece will be named in the for t code section? Meaning, I can position each track piece during game by calling it by its entity name (positionentity trackpiece,0,0,10) |
| ||
You're going to need to save the values that come back from CreateCube. You don't choose entity names, Blitz does. |
| ||
Better to use arrays for this:Dim track(10) For t=1 to 10 track(t)=CreateCube() Next Then, to position a track piece later in the game ; position track number 3 PositionEntity track(3),x,y,z Just to clarify things a little more: mycube=CreateCube() The 'mycube' bit is a handle which points to where that newly created cube lives in memory. |
| ||
yes you can, use NameEntity(handle,name$) and then make it the child of a global pivot, then use FindChild(parent,name$) |
| ||
Cubes may not be a good building block for creating racetracks. Depending of course on your specific game racetracks in games tend to be comprised of sweeping curves. You might be better off providing players with curves and straightaways for track pieces (sort of like the track pieces in a toy car racing set.) |