- Home /
Question by
colorcraft · Dec 13, 2013 at 01:21 AM ·
variablesnotworking
IEnumerator not working
if(Input.GetKeyDown(KeyCode.F)){
StartCourotine("AddApple");
}
IEnumerator AddApple() {
yield return new WaitForSeconds(7);
inventory.AddItem(InventoryManager.DeepCopy(item));
}
What am i Doing wrong ;-;
The IEnumerator is underlined red.
Assets/ApplePick.cs(34,21): error CS1525: Unexpected symbol (', expecting
)', ,',
;', [', or
='
I basically want a 7 second delay before this happens inventory.AddItem(InventoryManager.DeepCopy(item));
Comment
How is it not working? In the code snippet here you've misspelled 'StartCoroutine()', but that would generate a compile time error. If this is not your problem, please edit your question to include more of your script and add more description on how it is not working.
Best Answer
Answer by robertbu · Dec 13, 2013 at 02:25 AM
I don't know if this is a code fragment or if this is your real code. 'StartCoroutine' is still misspelled. Your code should be something like:
void Update() {
if(Input.GetKeyDown(KeyCode.F)){
StartCoroutine(AddApple());
}
}
IEnumerator AddApple() {
yield return new WaitForSeconds(7.0f);
inventory.AddItem(InventoryManager.DeepCopy(item));
}
Your answer
