|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
Asked By |
heavyathan |
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.
Could you show us the code which produces this error? Please properly copy, paste, and format any code you put here.
Ertain | 2022-05-18 19:43
|
|
|
|
Reply From: |
heavyathan |
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
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.
haydenv | 2022-05-19 09:40
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()