Ok I did use the search button before I posted, but none of the topics I could find were relevant. What I’m trying to accomplish is have like 8 or 9 different level pieces like (hallway, big room, bridge room, hallway2, etc…) and randomly add them together up to a certain point then cap all the openings with dead ends or whatever. I really have no idea how I would go about doing something like this. Can anyone point me in the right direction? Thanks.
Did you see Spg’s MiniDungeon? It’d probably be a good starting point.
http://forum.unity3d.com/threads/72525-MiniDungeon-A-Free-Randomly-Generated-Dungeon-Jump-Start
It works great I made my own pieces but theres a problem, when I change out the four-way piece with my own it gets messed up, the pieces are all really far away from each other, but when I replace the main piece with the main piece from the prefab but leave all my other pieces in it works fine. I can’t really try and fix the script because its in c#, could someone look over it and possibly redo it in javascript? or just tell me whats going wrong? I looked over at it and the piece is exactly the same as mine, same size and everything (except for the shape, its still a square but I added to it). Heres a link to the code as it was to long to post here. Thanks.
I’m thinking it will just be better to make my own.
I’ve made this, it branches out with random pieces (setup with markers and collision points in the 3D app), worked not bad, but I could never figure out how to make closed loops (it would branch out and randomly cap off dead ends). Have to see if I can dig that code/project up.
The exits could be at arbitrary angles and positions (had to watch out for rooms running over each other also)
Ok so I got the easy part down (spawning the blocks in rows to make a giant square, now I just gotta figure out how to make it spawn the right ones). Heres my current code
var pieces : GameObject[];
var pCG : int;
var canBuild : boolean[];
var buildLength : Vector2;
var bPA : boolean;
var buildPosition : Vector3;
var bPosOffset : Vector2;
var DungeonPieceNumber : int = 0;
var cPiece : GameObject;
var cCollider : BoxCollider;
var cSize : Vector3;
private var a : int;
private var b : int;
function Start(){
DungeonSpawn();
}
function DungeonSpawn() {
for(b = 0; b < buildLength.y; b++){
for(a = 0; a < buildLength.x; a++){
buildPosition.x = (bPosOffset.x * a);
buildPosition.z = (bPosOffset.y * b);
while(!bPA){
pCG = Random.Range(0, pieces.length);
if(canBuild[pCG]){
bPA = true;
DungeonPieceNumber++;
cPiece = Instantiate(pieces[pCG], buildPosition, pieces[pCG].transform.rotation);
cCollider = cPiece.AddComponent("BoxCollider");
cCollider.size = cSize;
}
yield;
}
bPA = false;
}
}
}