Skip to main content

Questions tagged [coroutines]

Coroutines are software components that generalize subroutines for cooperative multitasking. They are suited for asynchronous (or non-blocking) programming and allow program execution to be suspended and resumed.

Filter by
Sorted by
Tagged with
2 votes
1 answer
299 views

Is await/free in gdscript a potential memory leak?

Consider a situation where a coroutine in node A awaits a signal from node B. If node B gets freed without sending the signal, obviously the coroutine in node A will never finish executing. Does it ...
Carl Muckenhoupt's user avatar
0 votes
0 answers
51 views

Tried to queue enemy attacks but they attack too fast and simultaneously

I'm newbie with programming and Unity. I was trying to make a queue for the second enemy to attack only when the first finishes its attack, but it just doesn't work: they attack much much faster and ...
Daniel's user avatar
  • 1
0 votes
1 answer
60 views

WaitForEndOfFrame in a loop is not updating the inspector

My code has a function ...
Usylom's user avatar
  • 31
0 votes
1 answer
128 views

Why doesn't Coroutine work the way I want with if blocks?

I'm making a game and when the enemy dies I keep it in memory. I want the person playing to find the game just as they left it when they enter. I'm doing most of these, but there's one small problem ...
Volkan AKDAG's user avatar
1 vote
0 answers
172 views

How to use await with GDExtension-wrapped external library functions?

I am looking at wrapping functionality from an external C++ library with GDExtension for use with Godot 4. Many of these functions have an appreciable runtime before they return the values of interest,...
R.M.'s user avatar
  • 141
-2 votes
1 answer
104 views

How to make a coroutine private in Unity?

I am trying to make a coroutine private in Unity. I have tried declaring it as a private method, but it still seems to be accessible from other classes. Here is an example of the code I am using: <...
Alex Junior's user avatar
1 vote
1 answer
161 views

Audio won't pause in coroutine

I am making a system where I have one long audio clip made up of voice lines which I want to be able to play one after the other with a variable pause in between. I press the space key to start the ...
Michael's user avatar
  • 51
0 votes
1 answer
148 views

Moving Multiple Objects With Vector2.MoveTowards Not Consistent

Good Afternoon, I'm trying to move three objects from their current position to a shared target position based on speed. Once they reach the target position, they move to a shared respawn location and ...
PayasoPrince's user avatar
0 votes
3 answers
480 views

Coroutine delay isn't consistent on different framerates

My problem: I am using a coroutine to add a typewriter effect to my texts, but the delay (using yield return new WaitForSeconds();) isn't consistent on different ...
DemonicTree's user avatar
11 votes
1 answer
4k views

Are there limits to the number of coroutines in Unity?

While reading a thread about coroutines, I stumbled upon a random user's comment that coroutines may not fire at all: Just so you are aware, there is a coroutine limit and if you hit this some ...
Saturn's user avatar
  • 1,763
0 votes
0 answers
390 views

how do i get my coroutine to update every frame in my BepInEx plugin?

in the code linked below, i am using bepinex and harmony to make a plugin for the game Sons of The Forest the goal of the code attached is to log the value of an in-game variable every second, but the ...
naenae baby's user avatar
0 votes
1 answer
147 views

Can player input be missed while yielding WaitForSeconds?

I just wanted to fact check myself on a scenario where the player may be locked out of input. With this example, there is a chance that the player's input will not be received if they happen to press ...
PayasoPrince's user avatar
0 votes
2 answers
2k views

How to deal damage every 2 seconds while enemy is touching the player, rather than every frame?

I have made an up and down movement RPG prototype and I wanted to have a fighting system. I made it so that the enemy follows the player and that I get damage every time he collides with me. The ...
Hammynator's user avatar
0 votes
0 answers
952 views

Is there a way around using yield return null for coroutines to avoid waiting an extra frame at the end of my coroutine?

I've gotten used to using coroutines as a way to ensure a things are done sequentially in my code, i.e. instead of calling method a, method b, and method c on back to back lines I will sometimes yield ...
Kyle34562345's user avatar
0 votes
1 answer
447 views

Deal damage just once, rather than repeatedly till the enemy dies

I am new to making games with Unity. I am trying to damage the enemy. So far, the damage works. The problem is it will repeat it until the enemy is dead, but I want it to damage the enemy only once. <...
Spectral's user avatar

15 30 50 per page
1
2 3 4 5
7