0 votes

I have a custom file that contains multiple skeletons for multiple characters. I'm trying to import each as a skeleton so I can reference it to my meshes in code any time.

Here is my code:

for x in range(numChars):
    file.get_buffer(42)
    var skel = Skeleton.new()
    var skin = Skin.new()

    for _y in range(numCharBones[x]):
        var bonePIndex = file.get_32()
        var boneIndex  = file.get_32()

        var boneName  = "bone_%d" % boneIndex
        var bonePName = "bone_%d" % bonePIndex if bonePIndex >= 0 else ""

        file.get_buffer(98)
        var m0 = file.get_float()
        var m1 = file.get_float()
        var m2 = file.get_float()
        var m3 = file.get_float()
        var m4 = file.get_float()
        var m5 = file.get_float()
        var m6 = file.get_float()
        var m7 = file.get_float()
        var m8 = file.get_float()
        var m9 = file.get_float()
        var m10 = file.get_float()
        var m11 = file.get_float()
        var m12 = file.get_float()
        var m13 = file.get_float()
        var m14 = file.get_float()
        var m15 = file.get_float()
        file.get_buffer(192)

        skel.add_bone(boneName)
        var boneId = skel.find_bone(boneName)
        if bonePName != "":
            var bonePId = skel.find_bone(bonePName)
            skel.set_bone_parent(boneId, bonePId)

        skel.set_bone_rest(boneId, Transform(Vector3(m0, m1, m2), Vector3(m4, m5, m6), Vector3(m8, m9, m10), Vector3(m12, m13, m14)))

    skel.register_skin(skin)
    var outpath = "res://equips/%d.%s" % [x, get_save_extension()]
    var result = ResourceSaver.save(outpath, skel)

    if result != OK:
        return result

    r_gen_files.push_back(outpath)

Unfortunately, I keep getting the error: Can't save empty resource to path

func get_save_extension():
    return "skel"

func get_resource_type():
    return "Skeleton"

After further investigation, I found out that Skeleton is not a resource which means it cannot be saved. What are my options here? What are my alternatives?

asked Mar 4 in Engine by majidarif (24 points)
edited Mar 4 by majidarif

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.