Skip to main content

Posts

Showing posts from October, 2012

How To Instantiate Along A Grid (Simple City Generator Method)

A city created at run time that was instantiated along a grid.

The reason for this post is to allow people to understand how to make something like this easy and simple. The city is instantiated along a grid using the restraints of the length and width perimeters passed through into the generator. Tiles are incremented through a constant that defines the width/length of the tile square. Here's the code I've constructed for the current explanation :

var tileConstant:float = so and so number;

var tileObject:GameObject;

function BuildCity(desiredLength:int, desiredWidth:int){
var length:int=1;
var width:int=1;



while(length<=desiredLength){
                Instantiate(tileObject, Vector3(width*tileConstant,0,length*tileConstant), Quaternion.identity);


//incrementing if(length ==(desiredLength)&&width <desiredWidth){ length = 1; width +=1; }else{ length+=1; } }
}
This code it attached to an empty gameobject inside the scene!
So with this code now, we have a tile constant. Keep in min…

Backing Up Your Projects

What Prompted This Post:
Over the summer while working on one of my games, Unity 3D released an update which required your project to be "upgraded".It warned me to back up my project, but of course me being the stupid little high-school student I am, didn't even think twice and upgraded the project without any precautions. Upon the re opening of my Unity project, I was in shock. Where as the skeletons for all my prefabs, models, and materials still existed, they were all out of place and not put together. So a prefab of a enemy had the mesh component, but the mesh was not linked to it to render, the material was not linked to be rendered. The attached script was said to be missing (although still existed within my project, just not linked). This existed not only in prefabs but every game object in every scene. I was never able to get back my terrain (although height maps existed) so I had to end up remaking it. The whole process of linking everything back together took a…