0 votes

I have a double tap logic

var clicked = false
func double_input(input):
    if Input.is_action_just_released(input):
      clicked = true
      yield(get_tree().create_timer(0.5),"timeout")
      cliked = false
   if clicked == true: 
     if Input.is_action_pressed(input):
       return true

It works fine just as intended but if I print it out, the log will be like this:

null
null
null
null
[GDScriptFunctionState:1305]
true
null

I don't know why but I deduce that it prints the yield in my function, anyone knows how to deal with this?


EDIT:
I've got a workaround. I created a 'match' system that filters if it is object,bool or null and it's working.

Godot version 3.2.3
in Engine by (378 points)
edited by

InputEventMouseButton already has a doubleclickproperty.

Anyway according to the docs

Calling yield() will immediately return from the current function, with the current frozen state of the same function as the return value.

So this is intended behavior. You probably shouldn't be using yield() in this situation.

1 Answer

0 votes

When a func calls yield(), execution of the func stops and returns to whoever called the func. But since the func will resume after the yield is fulfilled, the returning value is the object GDScriptFunctionState which is actually the func object itself. Whenever a func returns this object, you know that it is in yield state.

https://docs.godotengine.org/en/stable/classes/class_gdscriptfunctionstate.html

by (134 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.