anima icon indicating copy to clipboard operation
anima copied to clipboard

An error is reported for the example animation

Open lrplrplrp opened this issue 7 months ago • 3 comments

Godot version:4.4 anima/core/keyframes-engine.gd Error animation:2DGrid Error line:56 Error code: if frame_keys[0] != 0: Error:Out of bounds get index '0' (on base: 'Array') Resolution: Line 29 if percentage is StringName: #if percentage is String:

lrplrplrp avatar Jun 28 '25 14:06 lrplrplrp

Could you provide an example code that I can use to reproduce this issue?

ceceppa avatar Jul 02 '25 15:07 ceceppa

@ceceppa This is an example that comes with the project, and the godot version is 4.4 https://github.com/user-attachments/assets/3c3be12b-a7fd-42f2-bca6-d8bf574c4a9f

lrplrplrp avatar Jul 03 '25 01:07 lrplrplrp

@ceceppa hi, I had the same error and it seems to be fixable by adding a StringName check, In keyframeEngine, line 29:

static func flatten_keyframes_data(data: Dictionary) -> Array:
	var result := {}
	for key in data:
		var is_dictionary = data.has(key) and data[key] is Dictionary
		var value: Dictionary = data[key].duplicate() if is_dictionary else {}

		if not key is Array:
			key = [key]

		for percentage in key:
			if percentage is String:
				if percentage == "from":
					percentage = 0
				elif percentage == "to":
					percentage = 100

to

	var result := {}

	for key in data:
		var is_dictionary = data.has(key) and data[key] is Dictionary
		var value: Dictionary = data[key].duplicate() if is_dictionary else {}

		if not key is Array:
			key = [key]

		for percentage in key:
			if percentage is String or percentage is StringName:
				if percentage == "from":
					percentage = 0
				elif percentage == "to":
					percentage = 100

there are some other bugs as well. Some of the declarative construction of animation is not working, but all the dictionary construction seems to be working well.

phosphorylation avatar Jul 29 '25 08:07 phosphorylation