How to make it so that if I press space for 3 seconds everything(every trees) on a radius disappear?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Jan Gabriel

I’m using this, but the players area 2d disappears too fast so the area 2d of the tree doesn’t detect it.

func _process(delta):
if Input. is_action_pressed("chop") and ChoppingTimer.is_stopped():
	chopping. disabled = false
else:
	chopping. disabled = true
:bust_in_silhouette: Reply From: ramazan

var t = 0

func _process(delta):
     if Input. is_action_pressed("chop"):
          t += 1 
          if   t > 200:  // note : 200 sample
               print("chop")

Of course there are other ways

One small change to make it work.

Delta is in Seconds
Other Ways of Doing Timing

var time = 0

func _process(delta):
     if Input. is_action_pressed("chop"):
          time += delta
          if   time >= 3: 
               print("chop")

codelyok13 | 2022-03-19 00:59

This works and this is a very good way to do this. But my problem is, how to make the axe hitbox disappear almost instantly after appearing.

  var time = 0
  var axeHitbox = get_node("AxeHitbox")
  func _process(delta):
          if Input. is_action_pressed("chop"):
        		time += delta
        		if time >= 3: 
        		AxeHitbox. disabled = false

Jan Gabriel | 2022-03-19 10:10

AxeHitbox.visible = false

and add

  func _process(delta):
      if Input. is_action_pressed("chop"):
            time += delta
            if time >= 3: 
                AxeHitbox. disabled = false
      else: t = 0 // add 

ramazan | 2022-03-19 13:50