Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Abdulelah444 |
Hi…
I want to give my character a gliding ability where at certain condition it starts gliding for a period of time then it drops down, I have everything done well, I made a simple bool condition if true , character glides if false it drops down…
now how do I toggle this Boolean?
I used coroutine yield it worked but it was not consistent, how do I get it to be consistent or how do I use a timer instead because I tried and it did not work well
Well how long should the gliding last? If it’s a set amount of time, then a Timer
is probably the most appropriate route to take and it should be consistent. In what way did it not work well?
i_love_godot | 2019-12-11 15:17
I couldn’t get it to work and I don’t know why…
func _ready():
hovering_timer.set_one_shot(true)
hovering_timer.set_wait_time(Gravity_Dilution_Time)
hovering_timer.connect("timeout", self,"On_hovering_timeout_complete")
add_child(hovering_timer)
func movement():
if Enable_Gravity_Dilution :
*logic*
hovering_timer.set_wait_time(Gravity_Dilution_Time)
hovering_timer.start()
func On_hovering_timeout_complete():
print("timeout")
Enable_Gravity_Dilution = false
I really don’t know how to use timer correctly, I came from unity and it was much easier using coroutines
Abdulelah444 | 2019-12-11 17:17
What behaviour are you seeing? And how does that differ from what you expect to happen? Is the timer running? Does “timeout” print to the screen?
i_love_godot | 2019-12-11 17:26
I am seeing no changes, timer has no effect what so ever and I would expect it to execute what’s under if Enable_Gravity_Dilution
for a period of Gravity_Dilution_time
after time runs out Enable_Gravity_Dilution
would equal false
and only reset back when is_on_floor()
is true
.
no "timeout"
does not print
Abdulelah444 | 2019-12-12 08:49