Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | qez008 |
I have a little script for a gun. I figured a coroutine would do nicely for handling reloading and reload cancelation. The script seems to work just fine from what I have tested, but I’m getting this error in the debugger:
E 0:00:13.779 resume: Condition ’ !function ’ is true. returned:
Variant() <C++ Source> modules/gdscript/gdscript_function.cpp:1836
@ resume()
I am using Godot 3.2.beta.5. I have tested and the error also occurs with 3.2.1
const CANCEL = true
var _pending_reload
func _reload():
var result = yield(get_tree().create_timer(.5), "timeout")
_pending_reload = null
if result and result == CANCEL:
return
bullets = FULL
func reload():
if not _pending_reload:
_pending_reload = _reload()
func use():
if bullets == 0:
return
if _pending_reload:
_pending_reload.resume(CANCEL)
# irrelevant fire bullet code
_pending_reload.resume(CANCEL) seems to cause it, as the error appears right after canceling a reload.
Why am I getting this error and how might I fix it?
edit: fixed a typo