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

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


Add existing variables to an array?

I have a few float variables and an array `public float zero = 10.5;` `public float one = 25;` `public float two = 50;` `public float three = 75;` `public float four = 12.5;` `public float five = -65;`...

View Article

Instantiating game objects in spiral pattern

I am trying to create grid tiles for a system in my game and without the proper algorithm right now it just starts spawning them from the bottom left side. for (int x = 0; x < width; x++) { for (int...

View Article

Path Generation in procedural terrain generation

Salam, Hi, I am keen to know if there is a way to generate paths while using procedural terrain generation. For example if I want to generate a map/terrain randomly with some certain number of paths...

View Article


HOW to USE LOOPS withinh Update???

HI Guys!!! i have fought with this!!! hehehe void Update(){ While(condition){ //actions } } Why would i do something like this? simple!! some situations could need it!! for example, if i try to develop...

View Article


how to tell if a for loop has completed

I've been having trouble with for loops. I've created a simple for loop that decides how far my units move for (int i = 0; i < moveSpeed; i++) { //moves unit if (i == moveSpeed) { path = null; } }...

View Article

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

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

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


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

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


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

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


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

My 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

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


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