Skip to main content

Posts

A Few Pointers On Switching From JavaScript To C#

One does not simply add to an array. In JavaScript you might have familiarity with using arrays. You might also be familiar with "adding" to arrays. Well Unity sugarcoated that for you. Arrays are not really re-sizable. When you declare an array in c#,  you have to define it right there. If your looking for something similar to re-sizable arrays, use lists. To use Lists in Unity c#, you must add the line " using System.Collections.Generic; " At the top of your code. Declaring a list of Game Objects would go something like this List<GameObject> myGameObjectList = new List<GameObject>(); Then adding to the list would is as simple as myGameObjectList.Add(gameObjectInstance); Then if you really just want an array you would say something like GameObject[] gameObjectArray = myGameObjectList.ToArray(); The API is not what it always seems. Unity has also sugar coated some of its API, some parts to the point where its practically ...

Making Multiple Instances of Windows With Same Window Method

So when developing a small little web-player, I ran into the problem of trying to render multiple instances of the same window function. My plan was for my user interface component to iterate through all the thought components and for each thought, render its contents in a new window. The windows need to be draggable also. My first attempt of this implementation failed. Rect thoughtRect = new Rect(20, 20, 200, 100); void OnGUI(){ for (int i = 0; i < allthoughts.Length; i++){ thoughtRect = GUI.Window(0+i, thoughtRect, DoThoughtWindow, ""+allthoughts[i].GetContent()); } } void DoThoughtWindow(int windowID) { GUI.DragWindow (new Rect(0, 0, 10000, 10000)); } For those who don't see the problem with this, I'll explain. All three windows are using the same Rect  thoughtRect  so all the windows are drawn on top of eachother. You might think this won't pose a problem due to the windows be...

Fixing Sketch Up blank window (white box) problem

When downgrading my OS over Christmas, I was faced with many problems, one of which is getting my Google sketch-up working. Almost everything was working perfectly, except one little thing, The 3D Warehouse. It was just displaying a blank screen . At first I thought I had blocked permissions for giving it internet access.  Though my computer said it was allowing it to go over the network. I tried turning off my firewall and still nothing happened. I don't have any anti-virus software so I didn't worry about that. Guess what fixed it this annoying problem? Updating INTERNET EXPLORER. Just check for updates, and updates for what ever you computers default browser is also. Now everything's back in harmony

Choose Binding Time Consciously, Awake and Start functions for Initialization

So I ran into a simple but annoying problem when I was trying to hurry up and finish a game I have been working on for a while so I could move on to start a new idea. I was being stupid an hard coding the last features I wanted to include in the game, and of course came across a problem that I spent 30 minutes on that I could of easily avoided if I was thinking. Here is how the problem began. I needed a way to keep up with all the Light projectors in my scene and figure out which ones are close to me. This sounded easy enough, but alas I managed to screw it up. The code I wrote  used an array that was set on the awake  method using GameObject.FindGameObjectsWithTag("TagName"); In my scene, the player is already in my scene, and the lights are not. When my scene is played, a script called GameInit calls the city generator which in turn calls the multiple factories, one being the factory that generates all the lights in my game. Although it looks like when my scen...

Making Images in GIMP Part Two

In the previous post about making images in GIMP, I went over the process of creating the composition and creating clean line art.  In this next part I will explain the steps I go through in coloring my picture, including flats, foreground, background, extra detail, and lighting. And let us continue! The next thing I did after making the line art was add a new layer on screen mode and filled it with an orangish-brown color.  This will tie the piece together in the end by giving all the colors a similar hue while they still pertain to their individuality.  The opacity of the screen is about 52% so that it's not too overwhelming.  Along with this I have brought down the line art layers to 80% opacity to give it a softer effect. Here you can clearly tell the palette I have chosen for this piece, it's going to be filled with earthy tones.  The flat colors for the foreground are fairly basic and cooperate with each other.  Don't be afraid to take...

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; } ...

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 ...