Loop and screen update (or debug log update)
I have a for loop going on, with for loop inside, and another inside... they are calling few other functions, also with for and while loops. Anyway it takes about 10 to even 400 seconds on my computer...
View ArticleChange game-cursor on gameobjects within range
Hi. I have a problem with the following code: using UnityEngine; using System.Collections; using UnityEngine.EventSystems; public class Move : MonoBehaviour { public bool Cursor_enemy = false; public...
View Articleif loop running when it shouldn't
In my videogame the player has to copy a text using the keyboard and the game, after checking the spelling of all the characters of all the words, updates the text to be copied in real time. So I...
View ArticleBreaking out of problem code
is there a way to set a kind of timer at the start of every frame that will cause an event if the time between frames is too high, like 10 secs for example, if you're getting an fps of 0.1 then theres...
View ArticleUnity keeps crashing due to unknown infinite loop?
Yo So I am very nooby with C#. I am currently following a tutorial to make a memory game (https://www.youtube.com/watch?v=prfzIpNhQMM). I have followed it all and managed to fix all problems I ran into...
View ArticleHow to destroy numbers after solving them?
I'm making a calculator game for my final project in a beginning scripting class. The premise of it is that randomly generated numbers are falling from the top of the scene, and when they hit a...
View ArticleUsing a coroutine to increment a for loop?
So I'm making a strategy game where the player will take their turn, then each enemy unit will go one by one, then the player's turn will start again. Right now what happens is it will cause all units...
View ArticleNested loop queston
I'm trying to create a 5 x 5 grid of spheres using a nested loop. it looks like this: public GameObject ball: for (int y = 0; y < 5; y++){ for ( int x = 0; x < 5; x++){ GameObject spheres =...
View ArticleWhy is this IEnumerator instantly crashing my game?
IEnumerator Dungeon() { int X = Random.Range (-3, 3)*2; int Y = Random.Range (-2, 2)*2; Vector2 pos = new Vector2 (X, Y); if (Vlist.Contains (pos) == true) { print ("repeated"); yield return Dungeon...
View ArticleCant loop through a List
Here is the code in question: public List craftingItems = new List(); public void checkIfItemIsCraftable(){ for (int i = 0; i < inv.database.craftingDatabase.Count; i++) { for (int x = 0; i <...
View ArticleC# Yield WaitForSeconds within For Loop
I am trying to use two yields within a coroutine loop (because I need to iterate out arrays with pauses between each loop). The first loop works correctly, with all the yields working for the right...
View ArticleTurn off script in multiple objects
So I am at loss. I am trying to find and disable script on each enemy object in game. I have foreach loop at awake that finds gameobjects with tag "Enemy", and finds script attached to it...
View ArticleWhile Loop Freezing Unity
What's wrong with this code? Whenever OnMouseDown is called unity freezes. public class createTroops : MonoBehaviour { public stats statsVars; public GameObject prefab; public int incPos = 4; void...
View ArticleComparing distance of vector 3's on a dynamic growing list
I have a script that is spawning treasure in random locations. I want the script to detect if a treasure has been placed, then save that placed position in a list. Once i spawn the next treasure, I...
View ArticleYield return statement ends loop execution
I've been working on a coroutine that splits text into a list of words, taking a break at every 500-ish characters parsed. See here: // charsToParsePerFrame = 500 // other code while...
View ArticleFor Loop looping out of Loop Condition
Hey guys, So this bit of error is confusing the heck out of me. For whatever reason, the for loop is not exiting after the loop condition is met: ![alt text][1] Notice the last 3 lines in the console,...
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 Article