Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Questions tagged [coroutines]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
42 views

Coroutine only partially executing

I have a Coroutine that I use to pull and spawn an enemy in my game. This coroutine works perfectly fine, with the exception of the very first call. I am fairly certain this is because I am probably ...
0
votes
0answers
21 views

How to make progress bar in EditorWindow with Threading in Unity?

I need to make a progress bar in EditorWindow. To do this, I perform the function of calculations in threads: Thread thread = new Thread (_worker.Work); thread.Start (); The class itself emitting ...
1
vote
1answer
45 views

Unity, WaitUntil in a self-made message box class

I managed to make a simple message box prefab with a Text and a Button through Canvas, and ...
8
votes
6answers
3k views

Why am I not getting stuck in the loop

I'm new to Unity. I was learning coroutines and I wrote this. ...
0
votes
2answers
81 views

Is coroutine as good as a delay() function [closed]

I'm new to Unity and I was learning the usage of coroutines. Is calling a coroutine as good as a delay() function? Does Unity have a delay() function?
0
votes
1answer
33 views

Bullet prefab gets stuck to target after hitting

As the title says, I am having an issue with prefabs: I am trying to make a bullet follow a curve and then hit a target using this method: ...
-1
votes
1answer
45 views

Coroutine does not resume after WaitForSeconds

None of the code after wait for seconds runs in the example below. The idea is to stop the player attacking for 1 second after he hits an enemy. When I run this code, ...
0
votes
1answer
34 views

How can I use a coroutine and GetAxis to rotate a game object?

For the sake of learning about coroutine, I want to convert the following to a cleaner Update that just calls a coroutine. How would I do that? ...
0
votes
1answer
29 views

Coroutine constantly updating animator transition

I have a problem for a while now and I am running out of ideas: I have a made a coroutine used to implement animations in the attacks, something like this ...
-2
votes
1answer
90 views

Why is my coroutines not working with in the if statement?

Isn't it possible to start co-routines under certain conditions? Or, it should only be started at the initial steps only? There is an enemy which will be de-activated after certain condition which ...
1
vote
0answers
41 views

Starting Couroutine in newly activated gameObject

I'm working on a UI system that animates an element's properties using coroutines. Every element that should be animated has a component called AnimatedUIElement ...
0
votes
0answers
49 views

Is a final yield return 0 required in corutines?

I have the following code run in a coroutine. I would like to know if the last yield return 0 is necessary and why. Thank you! ...
1
vote
1answer
49 views

Inflating a balloon while the user touches & holds the screen

I'm trying to create a simple balloon which will enlarge as the user touches and holds the screen. So I wrote something like this: ...
0
votes
1answer
103 views

Why even use coroutines in Unity?

I have been thinking about the use of Unity's coroutines recently, and while I've used them in the past, and am already aware of their bad reputation (although I've also seen posts on the unity forums ...
6
votes
2answers
462 views

Possible to yield a coroutine when it is taking too long to run?

Suppose I have a function that raycasts from (0,0,0) to every object in the scene. Sometimes the scene contains just a couple objects and sometimes it contains several hundred. Is it possible to ...
0
votes
2answers
406 views

Display loading screen after scene change but wait for coroutine to finish

I thought I'd understood how coroutines work but I'm still experiencing problems getting them to run when I want them to run: There are two scenes in my game: The main menu one and a game one. The ...
0
votes
1answer
366 views

Unity: Loading screen without a coroutine (is it possible?)

I need to accomplish something specific but I'm not sure how to do it exactly: My game has 2 scenes: The main menu that has a couple of buttons... ... and the game scene that displays a different ...
1
vote
0answers
44 views

Sequencing method calls with time delay

I'm trying to solve what seems to be (or should be) a very simple problem. I'd like to sequence several steps in a GameManager class with some time delay between them. In my case, I'd like to clear ...
0
votes
1answer
286 views

How can I make a coroutine run for a specific number of times in Unity?

I use coroutines in unity, with while(true) condition, which runs it indefinitely. I need to make the coroutine run for a specific number of times, let's say 10 times. Any pointers will be much ...
0
votes
1answer
55 views

Help understanding IEnumerator Move routine

I have this code and I know what it does (it will move an object up and down) But I don't know how its elements work. Could someone please explain it to me? ...
0
votes
1answer
1k views

How to create loading bar for asset bundles on Unity (without changing scene)?

So from the official documentation and unity forum now I know that there's async version of LoadFromFile (that I also will probably call ...
19
votes
1answer
4k views

What is wrong with my Respawn coroutine?

I am creating a 2D Platformer game in which if the player falls off the base/ground then I want the player to respawn at the nearest checkpoint. However I want there to be a delay between the player ...
3
votes
1answer
323 views

How can I optimize coroutines?

I have a script which has a Queue datastructure (code below). This queue holds more than 100 Actions. So currently my script does a yield return null after every ...
1
vote
1answer
282 views

Return value from coroutine to non monobehaviour

I have a class which is not a monobehaviour (lets call it "Generation"), and as such running CoRoutines from within are not an option. I have a monobehaviour (lets call this "TestScript") which needs ...
1
vote
1answer
145 views

In Unity, how do I use the extra time in every frame to do some extra processing?

Let's say, for example, that my target framerate is 60 frames per second. Now, I know that I have a maximum of 16.6 milliseconds to "do everything" every frame in order to maintain that framerate. ...
0
votes
2answers
820 views

Coroutine not working (Unity)

I made this code because I needed an image to display a couple seconds after an enemy spawns, but for some reason I can't make it work. There's no error in the console, but it doesn't display the ...
2
votes
1answer
3k views

How do I use coroutines to animate properly?

I have a coroutine, which I called from the Update() method on every click. First, I call AddTrunk() to add to my ...
1
vote
1answer
698 views

Recursive Unity Coroutine

I have a co-routine which is heavily reliant on calling itself to get the task done. I have tested it and the code works fine, the problem is that the co-routine will return every time that it enters ...
-2
votes
1answer
1k views

How to start a Coroutine in another script?

I did some research about this but what i found was kinda confusing so I didn't actually understand it. Basically I have a coroutine that displays an image after 5 seconds, but I want that image to ...
0
votes
3answers
3k views

On button click wait

I have a button I got from google material design asset pack which has a ripple animation when pressed. I'm using the button's click option in the inspector that calls a method that switches scenes. ...
-1
votes
1answer
379 views

Coroutine doesn't work

I've been trying to make this work for days and I can't figure it out. I have a code, attached to an enemy prefab, that should display an image a couple seconds after an enemy spawns (this is to show ...
11
votes
2answers
7k views

How to await async operations / coroutines?

I'm looking for a generic / reusable way to wait for coroutines and asynchronous operations to finish in Unity 5, similiar to C#5's await keyword. The simplest way ...
0
votes
1answer
161 views

Using a Coroutine in a character move left/right situation for a random amount of time

So what I am trying to do is have an AI character make decisions based on 3 zones, far distance, mid distance, or close range (not yet to close range). So far, the logic is set up so the character if ...
0
votes
1answer
4k views

Unity: How to resize a game object for a certain amount of time?

I've tried to make a coroutine like this ...
1
vote
1answer
171 views

How can I switch between starting a coroutine vs running the routine all at once?

I'm generating a level, and I have an optional delay to show the steps level generation one by one. If my generationDelay boolean is true, I want to use ...
2
votes
1answer
1k views

How to await player input using Coroutines

How can I accept player input using Coroutines, pausing execution of Unity while the player has not yet provided input? It seems like a simple problem, but I can't seem to figure it out. Here is my ...
1
vote
0answers
448 views

Get random point on NavMesh async

I am trying to spawn some entities on a navmesh at runtime. The entities need to spawn at a random point. Right now i use the following to get a random point: ...
0
votes
0answers
260 views

Difference between a normal function and coroutine without yeilding anything

I just came across a coroutine in my project, which does few calculation, which could have been done using normal function.There is no loop in that coroutine and contains ...
0
votes
1answer
23 views

IEnumerator Loop not Drawing Changes to Transform.position

So, I'm working on an IEnumerator() that is called to spawn objects in a fountain style (kinda flying up and out and landing at a random spot nearby). I feel like I had this working for a hot minute, ...
1
vote
1answer
173 views

How can I get separate caches for different coroutines? (Unity)

I want to fade out an image, so I have a coroutine FadeOut(). However, I want to have a separate image each time I call FadeOut. If I try to do something like this:...
1
vote
0answers
399 views

How do I correctly unload an additive Scene in WebGL?

I am creating an app in WebGL. I have a loading scene that I am loading additively: SceneManager.LoadScene("Loading Scene", LoadSceneMode.Additive); It loads ...
0
votes
1answer
66 views

GameObject that should have a fixed speed keeps accelerating

I'm using a coroutine to make a GameObject move from a random point A to a random point B. The GameObject should move along this trajectory at fixed intervals and at a constant speed. However, each ...
1
vote
1answer
2k views

NullReferenceException in StartCoroutine method

Maybe it's a repeated subject in the community but other answers didn't solved my question... I tried as the tutorial: http://answers.unity3d.com/questions/11021/how-can-i-send-and-receive-data-to-...
0
votes
1answer
63 views

Delaying the game to restarts with Coroutine

I want to create some sort of delay for the game to restarts when the ball is stops moving but the game keeps restarting whenever the velocity reaches zero. I want use a timer where the game will ...
-1
votes
1answer
251 views
0
votes
1answer
123 views

Showing the steps of a level generation process over multiple frames

I seem to be misunderstanding part of Unity. I'm generating a maze similar to the one here: http://journal.stuffwithstuff.com/2014/12/21/rooms-and-mazes/ I put the whole of the generation in ...
1
vote
0answers
406 views

Create a stack driven coroutine based state machine for Unity

I am working on a game where I am using a coroutine based state machine which is mostly a multi class implementation of this link. I am using it because it allows me to create multi frame sequences. ...
1
vote
1answer
451 views

StartCoroutine from other MonoBehaviour is not working

I am trying to replicate the model of Unity documentation about coroutines, but I want to partition it in another class: I have these two: ...
-1
votes
1answer
273 views

How do I use Couroutines for spawning and spawn certain amount of enemy AI in the scene?

I have made a spawn function for spawning enemy AIs, and it didn't work well in my scene. I have the enemy AIs spawning in the update function, and it initially works fine, but it's spawning too many ...
1
vote
1answer
221 views

How to track if an action is executing with IEnumerator and StartCoroutine

My code: ...