- Home /
The question is answered, right answer was accepted
Unity tells me that WaitForSeconds() "does not contain a constructor that takes 1 argument"
Hi, new here, have some experience with C#. So today i was adding some new coroutines to my code when suddenly all yield return new WaitForSeconds calls threw the same error: "does not contain a constructor that takes 1 argument"(They all have a float as argument). They have been working fine for a really long time and this is driving me nuts. Tried closing and opening Unity or Visual Studio but nothing changed. Also, it doesn't seem to recognize WaitForSecondsRealtime. Im using System.Collections so thats not the problem. It stopped working i think the moment i typed a new "StartCoroutine()". I'm hoping someone can help me with this! (Excuse my English, not native)
EDIT: I clicked the lightbulb in visual studio by accident, the compiler does not throw anymore errors, but now it just waits for the next frame, it seems as if WaitForSeconds as a function became WaitForFixedUpdate.
EDIT 2: Okay, solved it myself, it seems Visual Studio created a definition for WaitForSeconds that did nothing, i just deleted it and now it works fine, so all good!
You haven't defined your own WaitForSeconds() somewhere that's overriding the built-in one, are you?
Follow this Question
Related Questions
Coroutine doesn't work when called from another method. 3 Answers
Problem with coroutine 2 Answers
Looping a Script 2 Answers