0 votes

I have a timer in my Main scene and I want to be able to change its wait time according to how fast the game is. So I attached a script to this ObstacleTimer and I wrote:

extends Timer

func _change_wait_time():
    if TimeManager.VELOCITY >= 5.5:
        Timer.wait_time = 1.0
    elif TimeManager.VELOCITY >= 3.5:
        Timer.wait_time = 2.0
    else:
        Timer.wait_time = 3.0

func _process(delta: float):
    _change_wait_time()

This give me the following error:

Invalid set index 'wait_time' (on base: 'GDScriptNativeClass') with value of type 'float'.

I tried changing from float to int, but it gives me a similar error:

Invalid set index 'wait_time' (on base: 'GDScriptNativeClass') with value of type 'int'.

Can anyone help me solve this?

Godot version 3.4.2
in Engine by (15 points)

1 Answer

+1 vote
Best answer

instead of timer.wait_time = 1.0 try this self.wait__time = 1.0

by (436 points)
selected by
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.