Godot Version
4.4 Stable or 4.5 beta 3 GitHub build
Question
hi,
I’ve run into some problems modifying character animations because I need to rebuild the player object (a characterbody3d) each time I change the animations in the source file (usually a .glb file).
So my process is to change the animated model in blender, then export as a .glb into the project directory. I then rename the old player mesh in the CharacterBody3d object and load the new .glb into the scene. I then have to make it ‘local’ and copy the old AnimationTree into the new animated mesh hierarchy. Then of course I need to set the correct animation player in the animation tree.
I’ve had multiple problems with bad root motions and animations exporting with weird orientations so making the process faster would be greatly beneficial.
How can I take advantage of the fact that the new animation is essentially (was actually) the same file?
Cheers
You could try using an Import Script to automate some of the process you do.
Basically, you make a script that automatically runs each time the GLB file is changed. You have to make it a tool script and extend EditorScenePostImport. This type of script gives you access to the model scene that is generated by Godot once it’s imported.
I have one that automatically changes a JSON file with part_data for my customization system.
@tool
extends EditorScenePostImport
var clothePartsFolder: String = 'res://Assets/Models/Fighter/ClotheParts/'
var dataOutputPath: String = "res://Assets/Data/Clothes/clothes.json"
func _post_import(scene: Node) -> Object:
print("Importing clothing")
if not DirAccess.dir_exists_absolute(clothePartsFolder):
DirAccess.make_dir_absolute(clothePartsFolder)
var clothes := find_clothes_recursive(scene)
var clothe_data := create_dictionary(clothes)
if not clothe_data.is_empty():
generate_data(clothe_data)
return scene
Another recommendation is to use blender scripting to export your GLB file faster. It uses python, which is what GDScript is based on.
I haven’t seen an imported model come with an AnimationTree, the step of making the AnimationTree local and copying it doesn’t sound right. You could also set the old one inactive if it is playing. Are you overwritting the last glb file? I have great success overwritting the last file and have to replace nothing in the scene tree.