Find first empty "slot" in array
I am trying to make a function (in C#) that will return the first "empty" slot in an array. Lets pretend I have an array that looks like this: testarray[0] = Vector3(7,4,2); testarray[1] =...
View ArticleCreating a multidimensional array List
In my game, I need to make a List that contains a 3 dimensional array of floats. I can create a list like this: List testList = new List(); I also know how to create a multidimensional array, like...
View ArticleChanging a variable in another script for one object.
Ok, I already know how to change the variable in another script. All you do is this: GameObject.GetComponent(ScriptName).variableName +=1; But my problem is I have to change the variable TestVariable...
View ArticleHow to call a function in another script
I have 2 scripts (Javascript, by the way), scriptA and scriptB. By searching in unity's answers forum, I learned how to call a function in scriptA that is inside scriptB. Like this: ScriptA var...
View ArticleHow to create a variable in another object
In my game, I am creating many GameObjects in a 3 dimensional array like this: internal var chunks : GameObject[,,]; Now I want to put a variable into each game object. For example:...
View ArticleApply texture to a mesh on all 3 sides
I am working on a marching cubes terrain, and I need to apply a texture to it. The problem is, I don't know how to apply the texture so the mesh looks "normal" from any angle. Right now, Ive been doing...
View ArticleLayer Mask not working
I have read articles and other peoples posts about layer masks, and I can't get this to work. I am testing to see if a point in my game is within an objects mesh. So I found this code that easily does...
View ArticleMarching Cubes algorithm acting slow
I have finally finished a working, functioning marching cubes algorithm. I have my character, and I can dig holes into the "terrain" of the marching cubes mesh. (simaler to minecraft). The problem is,...
View ArticleCalling an Array[] for a function is sending an error.
I am working in java script, and creating an array. For some reason, unity is giving me an error "implicit downcast from object to int" Here is a sample of the code causing the error: internal var...
View ArticleFind the binary equivalent of a number
I have set up a function that acts like the first 8 digits of binary. Im trying assign each value in the binary code with its decimal equivalent. Look below too see what im trying to do....
View ArticleI don't know how to do multidimensional arrays
For some reason, unity wont let me create an 8 dimensional array like this: var verlist : int[,,,,,,,] = new int[2,2,2,2,2,2,2,2]; but has no problem with a 4 dimensional array like this: var verlist :...
View ArticleHow do you swap out the triangles in a mesh
I am generating my own procedural mesh. I use a 3 dimensional array that represents coordinates, and each coordinate is a vertex for the mesh. Then I draw triangles from vertex to vertex. Its pretty...
View ArticleUnity isn't reading the mesh I created
In my game, I am proceduraly drawing a mesh. I know how to draw the mesh, so now Im putting it into a function so I can call the function later. Here is my code so far: function Start(){ var block :...
View ArticleProblem with sending arguments through a function.
In my game, I have a 3 dimensional array called threeWay. In the update event, you can see in the code below that if a coordinate is set to true, then it will perform the function called DrawTheMesh...
View ArticleHow to assign a texture and shader
I am trying to procedurally draw a triangle given 3 coordinates. I have the triangle drawn ,but I don't know how to assign a texture and shader to the triangle. Here is my attempt: var shader : Shader;...
View ArticleHow to draw triangles with coordinates
Hello. I have set up a 3 dimensional array, which is used to "cover" the whole map with a 3d grid. The array is Boolean, so each coordinate is turned on or off. I want to make it so whenever an area of...
View ArticleHow to create a 3d grid of cubes
Hello. I am fairly new to unity3d, but have been coding with other programs for many years. I am not sure how to create a 3d grid of cubes (such as 10*10*10). What I want to do in the future is be able...
View ArticleFind first empty "slot" in array
I am trying to make a function (in C#) that will return the first "empty" slot in an array. Lets pretend I have an array that looks like this: testarray[0] = Vector3(7,4,2); testarray[1] =...
View ArticleCreating a multidimensional array List
In my game, I need to make a List that contains a 3 dimensional array of floats. I can create a list like this: List testList = new List(); I also know how to create a multidimensional array, like...
View ArticleChanging a variable in another script for one object.
Ok, I already know how to change the variable in another script. All you do is this: GameObject.GetComponent(ScriptName).variableName +=1; But my problem is I have to change the variable TestVariable...
View Article