![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Marre |
Hello! I’m still new to Godot and game devolping in general. Anyways I want to create a timer that starts when the player isn’t on the ground. I will use this timer so the player will be able to jump 0.4 seconds after he has fallen from the platform.
I don’t have any idea how to do it, but I have tried this:
#Movment Variables
const jump_force = -500
func _physics_process(delta):
#Input for vertical movment
if is_on_floor(): #checks if player is on floor
#Timer to check if 0.4 seconds have pasted
timer = Timer.new()
timer.set_wait_time(1)
timer.connect("timeout", self, "")
add_child(timer)
if (Input.is_action_pressed("move_up")):
motion.y = jump_force
#Movment of player
move_and_slide(motion, Vector2(0,-1))
As you see I haven’t connected the timer to a function. Bcs I thought it would be inefficient to make a whole function to just test if the timer is done. I also don’t know how to implement the timer into my if statement. So if there is any way to do it, I would be happy to know
//Marre