Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | WinstXD320 |
I have a problem with node timer. i made for code, but always when i want to start the time never start or if start, never call the function when the time end. Maybe is the structure of the code.
extends CharacterBody2D
var SPEED_ATTACK = 300.0
const JUMP_VELOCITY = -400.0
var IS_ATTACK: bool = true
var WAIT_TIME: Timer = Timer.new()
func _ready():
self.add_child(WAIT_TIME)
WAIT_TIME.wait_time = 2
WAIT_TIME.timeout.connect(func():When_time_end())
func _physics_process(delta):
up_direction
Attack()
move_and_slide()
func Attack():
if IS_ATTACK:
velocity.y = SPEED_ATTACK
if is_on_floor():
WAIT_TIME.start()
print(IS_ATTACK)
else:
velocity.y = -SPEED_ATTACK
func When_time_end():
print(IS_ATTACK)
IS_ATTACK = false