0 votes

Hi, all.
I'm having some problems with a timer. I get a bunch of errors as if the timer weren´t in the scene, which is not true, as it IS in the scene tree, declared in a onready var, and usually even started and stopped before in the game logic.

Any idea of what is happening will be appreciate.

https://imgur.com/pzOwpgn

enter image description here

Godot version Godot 3.4.4 GLES2
in Engine by (124 points)

Could you show us the code which produces this error? Please properly copy, paste, and format any code you put here.

1 Answer

0 votes

Below involved code. I've reviewed many times but I don´t find the mistake.

Its a kind of state machine, where states change according timers or triggering areas. I start/stop them when useless as I'm trying to get a mobile acceptable performance and many timers, -all of them set to Physics-, had impact.

Note that last function is triggered always before actual error function with no issue.

func _on_Update_path_timer_timeout():
    path_index = 0
    if player.vida == 0:
        estado_actual = estados.PATROL
    if estado_actual == estados.PERSEGUIR:
        update_path(player.global_transform.origin)
    elif estado_actual == estados.PATROL:
        if !actual_point ==null: 
            update_path(actual_point.global_transform.origin)
        else:   return

func _on_Attack_timer_timeout():
    puede_atacar = true

func _on_Area_ataque_body_entered(body):
    if body == player:
        Update_path_timer.stop()
        $Attack_timer.start(randi()%2+1)
        if !regen_timer.is_stopped():
            regen_timer.stop()
            heal_graphic.emitting = false
        estado_actual = estados.ATACAR

func _on_Area_ataque_body_exited(body):
    if body == player and estado_actual != estados.RETROCEDER:
        Update_path_timer.start()
        _on_Update_path_timer_timeout()
        estado_actual = estados.PERSEGUIR

func _on_Campo_vision_body_entered(body):
    if body == player:
        var dist_player = (player.global_transform.origin - global_transform.origin).normalized()*2
        var muro = ray.intersect_ray(global_transform.origin+Vector3(0,1.5,0), 
        player.global_transform.origin+Vector3(0,1.5,0)+dist_player, [self])
        if !muro.collider.is_class("KinematicBody"):
            return
        _on_Update_path_timer_timeout()
        Update_path_timer.start()
        $Campo_vision/CollisionPolygon.disabled = true
        estado_actual = estados.PERSEGUIR
by (124 points)

Since I don't see any issue in that code I'm thinking it might be in the part of your code where the variable Update_path_timer is assigned.

I dont see any code there with any timers being added. Where is the code where you are adding the timers?

Are these timers already in the code? Is this script on the update path timer? If not I think it should be

$Update_path_timer.start()

not

Update_path_timer.start()
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.