Hello and thanks for looking! This works as expected:
var TimeArray = [1.01, 2.01, 3.01, 4.01]
var Ticks = 0.01
var Place = 0
func _on_Timer_timeout(): # (once per second)
Ticks += 1
print(Ticks)
Place = TimeArray.find(Ticks)
print('position in array = ' + str(Place))
output:
1.01
position in array = 0
2.01
position in array = 1
3.01
position in array = 2
4.01
position in array = 3
5.01
position in array = -1
This does not work as expected:
var TimeArray = [1, 2, 3, 4]
var Ticks = 0
var Place = 0
func _on_Timer_timeout(): # (once per 0.1 seconds)
Ticks += .1
print(Ticks)
Place = TimeArray.find(Ticks)
print('position in array = ' + str(Place))
output:
0.1
position in array = -1
0.2
position in array = -1
0.3
position in array = -1
0.4
position in array = -1
0.5
position in array = -1
0.6
position in array = -1
0.7
position in array = -1
0.8
position in array = -1
0.9
position in array = -1
1
position in array = -1
1.1
I expect that when Ticks value reaches 1 I would get "position in array = 0" instead of -1
Been at this for days Pls Halp. Thanks!
(background for issue: NPC needs to perform actions at given times, times come from array that will change regularly)