Godot Version 4.2.2
Im trying to create a menu for my game and while running the code I get this error
Invalid set index ‘blend_position’ (on base: ‘null instance’) with value of type ‘int’
Honestly im new in godot and I’ve trying to search how to fix it but I have no clue, I’ve created the animations in the animationtree, im using the animation node blendspace1d, does anyone knows what is missing? or how can it be fixed
extends Control
@onready var scroller : ScrollContainer = $VBoxContainer/ScrollContainer
@onready var animation_tree : AnimationTree = $AnimationTree
var is_scrolling : bool = false
func _ready() → void:
#yield(get_tree(), “idle_frame”)
await get_tree().process_frame
scroller.scroll_horizontal = size.x * 2
pass
func _on_scroll_container_scroll_started() → void:
is_scrolling = true
set_process(true)
func _on_scroll_container_scroll_ended() → void:
is_scrolling = false
func _process(delta: float) → void:
var scroll = scroller.scroll_horizontal/size.x
if is_scrolling:
animation_tree['blend_position'] = scroll
elif abs(int(round(scroll))-scroll) > 0.1:
animation_tree['blend_position'] = lerp(animation_tree['blend_position'],int(round(scroll)),0.1)
scroller.scroll_horizontal = lerp(scroller.scroll_horizontal,size.x * int(round(scroll)), 0.2)
else:
animation_tree['blend_position'] = int(round(scroll))
scroller.scroll_horizontal = size.x * int(round(scroll))
set_process(false)