Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A simple way to do this will be to use the yield.
- First define a signal by
- signal mouse_click
- Then you need to listen for the mouse click in _input process.
- func _input(event):
- if(event.type ==InputEvent.MOUSE_BUTTON and event.is_pressed() and not event.is_echo()):
- emit_signal("mouse_click")
- Then inside myFn1,
- function myFn1():
- print("this will run right away")
- yield(self,"mouse_click")
- print("this will wait for mouse click")
- Hope this works, please check this because I'm typing on mobile.
- answered Jul 14 by vinod (382 points)
- Comment
- As I mentioned in my post, I have already tried coroutines. All this does is pause myFn1() mid-execution, but for some reason doesn't stop myFn2() from being executed normally.
- I don't know why, but that's what happens.
- commented Jul 14 by Adham
- I am using coroutines without problems.
- How are you calling the two functions?
- I'm just making sure of something.
- If you are calling like this,
- myFn1()
- myFn2()
- and the yield is inside myFn1, then both functions will run without waiting.
- You need to call like this,
- myFn1()
- yield....
- myFn2()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement