excellent tutorial, how do I make it so that it is activated only 1 time for each jump, because like this, you can go around the map only using dash, it is infinite
You have to add a dash counter that resets when you want it to. It would be easiest if the dash is only possible in the air and the counter resets as soon as the player touches the ground Something like this: var dashCounter = 0 ... func _physics_process(): ... #rewrite dash activation if Input.is_action_just_pressed("attack") && not is_on_floor() && dashCounter < 0: dashCounter = 1 ... if is_on_floor(): dashCounter = 0
@@DevDrache Thank you for your response, it helped me a lot, yes a correction "if Input.is_action_just_pressed("attack") && not is_on_floor() && dashCounter < 1:" must be less than 1 dashCounter. works perfect using your idea
With this code you can only do it once in a jump and reset it as soon as you touch the ground: var dashCounter = 0 var dashLimit = 1 ... func _physics_process(): ... #rewrite dash activation if Input.is_action_just_pressed("attack") && not is_on_floor() && dashCounter < dashLimit: dashCounter = 1 ... if is_on_floor(): dashCounter = 0
At the top of the code you need another variable like: var dashOnCooldown = false The dash activation must be extended: if Input.is_action_just_pressed("attack") && not dashOnCooldown: When Dash is activated, the variable is set to true: ... if Input.is_action_just_pressed("attack") && not dashOnCooldown: dashOnCooldown = true ... Then you only need one more timer and set dashOnCooldown to false with the signal from the timer.
sure, I'll put it on the list. do you need it with line of sight (LOS) or without? Maybe I can help you with a few explanations until the video arrives: Give the enemy an area node which then checks whether the player enters the area. Then you can use the size of the area node to determine when the opponent sees the player. if you need LOS check, then you have to work with raycasts and the player position.
@Dunkable works, but has a few problems. with a static raycast: if the player comes from above or behind, the enemy will not react. it is also not 100% of the same direction. with a flexible raycast (search at the player position): you have an automatic line of sight (LOS) check. Here it depends on whether you want this or not.