![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Skyline |
How to make 10 second timer and when jetPack(kinematicbody2D) up stop?
thank
Example image:
Add a Timer component.
Go to Inspector set the wait_time to 10 and then click in Node.
Double click in timeout() and link to your script. This will create a function _on_timer_timeout() in your script. Write the code to set the motion or velocity to 0.
Somewhere in your code, activate the timer:
if Input.is_action_just_pressed("ui_up") :
if get_node("Timer").is_stopped():
get_node("Timer").start()
Don’t forget to stop the timer. You may use the option one shot for this or in your script inside _on_timer_timeout() write get_node(“Timer”).stop()
P.s.: Depending of the nodes you may use get_parent().get_node(“Timer”)
Alex Pires | 2019-02-21 16:59
thank
I’ll edit
Skyline | 2019-02-21 17:02
Alex Pires, thank
I got
Skyline | 2019-02-21 18:17