class_name ArrayUtils static func get_sclosest(array:Array, target:Variant, error = 0): var floor = 0 var ceil = array.size() - 1 var closest = error while floor <= ceil: var searchPoint = floor((floor + ceil) / 2) var num = array[searchPoint] if num <= target: closest = searchPoint floor = searchPoint + 1 else: ceil = searchPoint - 1 return closest