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

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

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


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