Array Index is out of range
I'm having trouble trying to set up some stats using a for loop. I'm getting an array index is out of range. The thing is I know for sure that I've set up all the arrays in the inspector and all the...
View ArticleEnumerator in for loop acting strangely
Hiya, i'm trying to make it so that a random orb gets selected, after which the ID of the orb gets stored in an array untill the specified number of orbs get stored. However when i use this snippet,...
View ArticleLoops when generating random string
I am currently working on a program that generates a series of keys based on various factors, the basics are all down however right now I am running into issues where my generator that is supposed to...
View ArticleCoroutine with multiple Loops
Hi, I've checked the documentation, tutorials and read relating Q/A but it seems I can't find a solution. I use a coroutine to place a number in the center of the screen and then move a letter from the...
View ArticleFor loop not working
Hi. I am trying to use two for loops together, however only the first one is working and the second is not. Please help me out. public GameObject[] day; private int dayno; public void Start(){ day= new...
View ArticleCrossfade between multiple loops with 3 audioSources ?
Hi all, I have moving Objects that play different loops, depending on their velocity. I want to crossfade between the loops, like: vel = 0; vol1 = 1, vol2 = 0, vol3 = 0 vel = 0.2; vol1 = 0.8, vol2 =...
View Articlei have a list of transforms and i want to spawn a prefab once for all the...
as above but i just can seem to get this working at all! sorry if the question is structured bad in advance, its my first post. if i have: //generated on start int numAliens; //generated on start. a...
View ArticleDynamically create variable name from a loop
Let's say I have a list of hats as children in a UI panel, Each hat has a correct name of what it is, such as Tophat, Cowboy, Fedora, etc. Whether or not their unlocked is stored in bools named...
View ArticleDictionary creates copy, rather than references
I'm looking to create a dictionary to use strings to refer to bools reflecting whether or not an item is unlocked. I thought I could do this with: Dictionary hatDict = new Dictionary(); //the booleans...
View Articledo...while with Transforms?
I'm attempting to create a framework wherein I can move an object, regardless of type, along a set path defined by an n-dimensional array of path waypoints. In the following method, `_currentTarget`...
View ArticleHow can I loop through every 3D point on a plane's surface in C#?
I'm making a model editor for Unity 5 that will allow the developer to draw an image, and then inflate the image into a 3D object. Of course, it would not inflate transparent points. In order to do...
View ArticleMake player face different enemies with the same tag, based on distance
i´m trying to make my player face different enemies based on witch enemy is the closest. i´m trying to face the closest enemy using transform.lookAt and Vector3.Distance, i´m able to make the it work,...
View ArticleHow do I stop sound from looping on button press again
I have a simple button script for a two state button, but I'm having trouble trying to figure out how to make the sound stop looping when I press the button again. Here is what my script looks like....
View Articledo-while loop problems
I have a script to spawn an object in front of the player, and then move the player to a child object ("Target") of the the spawned object ("Straight"). However, my do-while loop messes things up....
View ArticleTrying to name a gameObject - loop suddenly exiting.
Hoping you can help! Comments in code. Any help appreciated. for (int t = 0; t < atomcount; t++) { if (element [t] == "C" && chain[t] == "A") { atom = Instantiate (carbon, new Vector3 (x[t]...
View ArticleHow to make an object do a multiple tasks forever
I want to make an object rotate left (either a certain amount of degrees/for a certain amount of time, whichever is easier) then rotate right for time/degrees and have that repeat forever. How would I...
View ArticleMake a GameObject changes between 2 colors with a time wait
Hey guys, I'm making a simple 2D game, I'm stuck at this issue. There's a sprite (square) and it moves horizontally in a fixed speed, but the square color is changing between Blue and Red, It start...
View ArticleInstantiating in a for loop is causing an infinite loop?
ok, so I have been trying to figure this out for two days now. The for loop in my StartingFloor() function works fine if I comment out the instantiate like, but otherwise, it crashes. var Tile :...
View ArticleHow to use infinite loops or alternatively repeated tasks
I know this is all very bad code, but it's just a concept. I want to have something walk in a square so i've given it four points and positions and have it walk there. It should work if i ran it once,...
View ArticleMy Coroutine Ignores the Boolean
In another script, a bool controls when this coroutine starts and stops: IEnumerator SpawnWaves () { if (SceneManager.GetActiveScene().buildIndex == 7) { shrinkStage = true; } if (shrinkStage == false)...
View Article