0 votes

I'm using a timer to limit how long a missile exists. I want to be able to adjust this based on the quality of the weapon used.
scene structure is area2d/timer.

code:

extends Area2D

var vel = Vector2()
var pos = Vector2()

func _ready():
    $range_timer.wait_time = world.missile_stats["range"]
    print( str($range_timer.wait_time) )

func _on_range_timer_timeout():
   queue_free()

This does print out the waittime I set, but the missile lives for the amount of time that is set in the GUI's node inspector.
I have also tried to adjust with a local variable and fixed float/int values, tried setting the node inspector value to 0.0 and tried the older code of .set
wait_time() (which is not valid code any more.)

in Engine by (70 points)
edited by

2 Answers

0 votes
Best answer

Is your timer set to autostart? Disable that and add $range_timer.start() after you set the wait_time.

by (22,067 points)
selected by

I should have thought of that. ...but won't forget it now!! Thank you very much!!

+1 vote

I think the proper setter of wait time should be

$timer.set_wait_time(time_you_want)
by (35 points)
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 Frequently asked questions and 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 [email protected] with your username.