system
1
|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
Asked By |
berez |
I am getting this error: Invalid set index 'set_wait_time' (on base: 'null instance') with value of type 'float'.
when start()
is called.
duration
and frequency
are timers and child nodes.
const AMPLITUDE = 20
const DURATION = 0.2
const FREQUENCY = 15
func start():
$duration.set_wait_time = DURATION
$frequency.set_wait_time = 1/float(FREQUENCY)
$duration.start()
$frequency.start()
I am new so I’d greatly appreciate if you could help
system
2
|
|
|
|
Reply From: |
yrtv |
And where start()
is called, do you check if all nodes are ready?
$duration.set_wait_time = DURATION
$frequency.set_wait_time = 1/float(FREQUENCY)
One of your nodes is not ready (null instance) then this part is executed. So you assign float to something what not yet exist.
Like this or not? I tried this and it did not work.
func turn():
var screenShake = preload("res://levels/screenShake.gd").new()
screenShake.start()
.
onready var duration = get_node("duration")
onready var frequency = get_node("frequency")
func start():
duration.set_wait_time = DURATION
frequency.set_wait_time = 1/float(FREQUENCY)
Sorry if I am being stupid.
Oh, I think I did use GDScipt instead of PackedScene.
I’ve fixed it now.
Thanks a lot!