[C#] How do I instantiate multiple objects at the same time?
I'm instantiating two capsules with force. When I make one a prefab that has the other as a child, One of the capsules sort of shakes on the spot while the other shoots forward. I read on another...
View ArticleTrying to loop through object distances?
Player starts out with some amount of fuel and life support. If they get their ship to a planet, their ship 'refuels' and they are back to full fuel and life support, otherwise these values are drained...
View ArticleHow do i use foreach/for loops properly?
Hello, I'm currently starting to expand my skills in the gui side of scripting, I've seen that foreach/for loops can be used to give each i in a list the same property or do something * the amount of...
View ArticleMecanim animation keeps running infinite
I made a character controller with mecanim and I have an idlestate for idling, a locostate for walking and a runningstate for running. The transition from walking to running is a boolean called...
View ArticleToo many nested loops cause fatal error(?)
I have 2 nested loops, each has 9 or 10 foreach loops and if statements nested. When I try to play in editor, I get an error message that says "Fatal error! Could not allocate memory : System out of...
View Articlec# loops not working yet no erors
hi so ive just started learning c# and ime coming across a problem with loops where despite no erors coming up the loop dosent seem to be working if i put print in it dosent print anything out but if i...
View ArticleDoWhile Loop is crashing Unity. Why?
The do while loop within the following script crashes Unity every time I try to run the scene. If I take the loop out of this script it runs fine, but with it in, Unity just freezes when I hit play....
View ArticleHow can I make a button follow the menu it's attached to?
Hello I am working on a game that has a small form factor menu that slides out when the player presses it. The menu has a set of 3 buttons that when pressed, will collapse themselves and make room for...
View ArticleYield return inside a loop slowdown problem
During Update (and using flags to call it whenever I do certain button presses) I call the FlipDiDoo coroutine to rotate a group of gameobjects. IEnumerator FlipDiDoo() { float anguloDeseado = 0.0f;...
View ArticleHow to make loop with call to IEnumerator actually pause?
Hello all, I am calling my function enterFlightMode which I am trying to make last ten seconds. 1 second per iteration. Heres the code. IEnumerator oneSec() { yield return new WaitForSeconds (1.0f); }...
View ArticleLooping through numbered scenes
I'm new to Unity and trying to create a simple memory game where objects on unique backgrounds appear on the screen for a few seconds in a specified order. Each object is it's own scene number 1-60. I...
View ArticleStep Sound Help
Hi! I have been trying to make some simple step sounds for my game. I have tried IEnumerator, loops but nothing have worked! This is a simple cut version of the script. It still contains the more...
View ArticleLoop music between special times
Hi! I have a clip that I use as music and it got a great start to it. So I want the start to start playing but it never plays again. Like setting custom end times and start times for loops but still...
View ArticleArgument out of range
I have a function that has the following code: int random = Random.Range( 0, playerCards.Count - 1 ); return playerCards[ random ]; The function throws an "Argument out of range exception", right...
View ArticleSequential Coroutines sometimes halt
Hello, I've been working on improving my Dissertation Project from University. This game creates a bunch of rooms, so ive been implementing Coroutines to create the map over time, rather than just in...
View ArticleCollumns Match 3 remake - Help with matchmaking and neighbor gems of same type.
Hello all, I am writing a columns (SEGA) match 3 remake type game. I've adopted several methods for my design on setting up my grid (2D Array), spawning gems, moving and collision withOUT colliders....
View ArticleHow to create a square using Linecast & loops?
I'm trying to draw a square using loops but no success so far. This is one of my many attempts: for (int i = 0; i < 1; i++) { Vector2 start = new Vector2 (collider.bounds.min.x +...
View ArticleCan i restart my for loop from 0
Is it possible to restart my for loop under a certain condition? What im trying to accomplish is getting a tile that is not on the border of the map using a for loop but for some reason it is still...
View ArticleHow to start an infinite loop that cycles between two actions?
Ive been trying to program a simple infinite loop in C# that forces a game object to move up until it reaches 3f, then down until it reaches -1f, then up again. I want it to repeat infinitely until I...
View Article