Quantcast
Channel: Questions in topic: "loops"
Browsing all 184 articles
Browse latest View live
↧

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 Article


Change 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 Article


if 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 Article

Breaking 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 Article

Unity 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 Article


How 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 Article

Using 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 Article

Nested 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 Article


Why 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 Article


Cant 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 Article

C# 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 Article

Turn 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 Article

While 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 Article


Comparing 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 Article

Yield 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 Article


For 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 Article

Crossfade 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 Article


i 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 Article

Dynamically 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 Article

Dictionary 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
Browsing all 184 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>