- Home /
Problem With Functions and Yield
function somefunction(){ yield; print("test"); } somefunction();//---> test
var someotherfunction = function(){ yield; print("other test"); }; someotherfunction();//---> Nothing
var somethirdfunction = function(){ //yield; print("third test"); }; somethirdfunction();//---> third test
Does anyone have an idea as to why yield doesn't work in functions which are assigned to a variable? And how to possibly get it to work correctly?
Thanks
Answer by Mike 3 · Mar 04, 2011 at 03:37 AM
You'd have to call StartCoroutine on them manually.
The issue is that javascript hides the implementation here, calling StartCoroutine implicitly on yielding functions which are called when not assigning them to anything.
var someotherfunction = function(){ yield; print("other test"); };
StartCoroutine(someotherfunction());
Hi, thanks for this answer. It solved my problem, too.
Your answer

Follow this Question
Related Questions
Some yield mess 2 Answers
yield WaitForSeconds preventing further actions. 1 Answer
Why is my delay not working? 2 Answers
pause charactercontroller movement briefly? 1 Answer
Definition of Script.function() depends on Script.function()... 3 Answers