Godot Version
Godot_v4.5-stable_win64
Question
I plan on having variants to the cats that spawn and I’m trying to do it through changing the values on the animation player for each that spawn. Unfortunately for every new instance that spawns, the sprite of the previously spawned instance is also changed to the newest spawn. Is there a way to prevent this thank you
tscene of the cat:
func _ready() -> void:
var variant = randi_range(0,7)
var animation1 = $AnimationPlayer.get_animation("Cat1")
var track1 = animation1.find_track("Sprite2D:frame",0)
animation1.track_set_key_value(track1,0,variant)
animation1.track_set_key_value(track1,1,variant+8)
var animation2 = $AnimationPlayer.get_animation("jump")
var track2 = animation2.find_track("Sprite2D:frame",6)
animation2.bezier_track_set_key_value(track2,0,variant+16.0)
tscene of the summon positions
func _on_main_summon() -> void:
summonblock = randi_range(1,3)
spawnentity = randi_range(1,2)
match summonblock:
1: summonpos = $Area2D.global_position
2: summonpos = $Area2D2.global_position
3: summonpos = $Area2D3.global_position
if spawnentity == 2:
var catspawn = cat.instantiate()
get_tree().current_scene.add_child(catspawn)
catspawn.global_position = summonpos
else:
var obstacle = obstacle1.instantiate()
get_tree().current_scene.add_child(obstacle)
obstacle.global_position = summonpos