0 votes

Im trying to make a timer for invncibility but for some reason it doesn't work..
here's my code:

extends Area2D


const hitEffect = preload("res://Effects/HitEffect.tscn")

var invincible = false setget set_invincible

signal invincibility_started
signal invincibility_ended

func set_invincible(value):
    invincible = value
    if invincible == true:
        emit_signal("invincibility_started")
    else:
        emit_signal("invincibility_ended")
onready var timer = Timer

func start_invincibility(duration):
    self.invincible = true
    timer.start(duration)


func _create_hitEffect():
    var effect = hitEffect.instance()
    var main = get_tree().current_scene
    main.add_child(effect)
    effect.global_position = global_position - Vector2(0, 8)






func _on_Timer_timeout():
    self.invincible = false


func _on_Hurtbox_invincibility_started():
    monitorable = false


func _on_Hurtbox_invincibility_ended():
    monitorable = true

any help would be greatly appreciated!

in Engine by (32 points)

1 Answer

0 votes
Best answer

Nvm my dumb a** figured it out lol

by (32 points)

Glad you figured it out, but you really should outline the actual answer/fix in case it's helpful to someone else with a similar problem in the future.

No no, it was just a slight misspelling in my code lol

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.