Skip to main content

I cant do retargeting with Godot, but can do other things

 Yesterday I spent part of the night trying to confirm that I cant reuse a Mixamo animation in Godot in some simple way. In Unity the process, though not trivial, was quite easy. I simply could not accept that Godot, after so many years in development, would not let me use an animation external to the model.
After looking at the editor, I tried the most obvious way: exported a model without animations and took my Mixamo generated FBXs containing the animations. To my surprise, if you export to FBX a model without animations, Godot doesnt imports it with a corresponding AnimationPlayer node, even if it has an armature. But if you export with the BetterCollada exporter it does include the AnimationPlayer, without animations, of course. With the model imported, there was no way to force it to use the Mixamo animations. But if you open the animations, you can use the Animation tool to save the animation data, and load it in your model. I did it! I thought.
Well, I didnt. Yes, you can make your model load the external animation track you previously saved. But it wont work. In the best case, your whole model will wag, or some parts will move, dragging the other inmobile parts. I even tried with the 4.0 branch from github and made most of my tests there: exporting to Collada, FBX and GlFT.
Why do I insist in this? You can perfectly make the game without it. But I think that it is more optimal to have a single animation that can be reutilized by all the similar models, and that the engine should provide such feature. Probably Im not the only one who thinks that way.
This raised another question: how can i equip and unequip items? Well, I found the solution quickly. I exported the item mesh, the gloves in this case, with the armature, as I did with Unity (FBX worked fine).  Then I saved the MeshInstance:




And did the same for the original body parts, the hands. For this case, I opened the exported model not as an inherited scene, because I was getting some errors saying that I had to make the mesh unique. In a script added to the top node in the character model (could be anywhere, of course), I put this:

extends Spatial

var gloves = "res://Models/male-alejandro-dae/iron_gloves_anim.tres"
var hands = "res://Models/male-alejandro-dae/male-hands.tres"
var equip:bool

# Called when the node enters the scene tree for the first time.
func _ready():
    equip=false


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
    if Input.is_key_pressed(KEY_SPACE):
        if !equip:
            var res = load(gloves)
            get_node("varsoi_male/Skeleton/varsoiM_hands").mesh = res
            equip = true
        else:
            var res = load(hands)
            get_node("varsoi_male/Skeleton/varsoiM_hands").mesh = res
            equip = false

Not the best way (consider that Im a total newbie), but pressing space switches from bare hands to gloves. The equiped gloves follow the character animation. I just get a weird error in the editor when running the project saying that the format of the required archive is unknown.



Now the next question is, what happens if I add an item, like an armor, using BoneAttachment? Will it follow the character animation? Well, I went to bed late, but got an answer to that too. Yes, you can use an static armor (that is, without armature) and place it in a BoneAttachment. It follows the character animation. Here I faced some problems: unlike the gloves, the exported mesh had a different scale and I had to play with it to make it fit. Both the gloves and armor came from the same blend file, I dont underestand why the difference. Perhaps because of the armature.
Even when I used 4.0, I think that all that can be implemented in 3.2 too, maybe with better results, as  the Vulkan branch is quite unstable yet and the FBX importer has little flaws. Please if you have any suggestion to improve this, feel free to leave a comment.

Comments

Popular posts from this blog

Unity3d isometric camera tutorial

I had pending this since a month ago, so Im forcing myself to post it today. The goal is to provide a fully functional isometric like system that you can use with few or none modifications in your own game. So, lets get started. Start Unity3d and in your scene, add an empty GameObject, we will call it target . Create a camera object and drag it to target to make it child. The result looks like this: Now select Camera and set the values to this: For a true isometric like feeling, ortho projection is essential. You could use perspective, but it is not the same. Play with Size to suit your needs (we will be using this later, when implementing zoom). Now, lets create an script named CameraController, or whatever, and drag it to target GameObject. Lets implement scrolling, the easier part: go to Update() and add the following code: if (Input.GetKeyDown(KeyCode.W)) {             dir = UP;         } else if (Input.GetKeyDown(KeyCode.S)) {             dir = DOWN;         } e

Isometric camera with Godot

Took some effort and some of my sleep hours, but at last, I made it. Here is my first videotutorial: implementing an isometric camera in 3D, with Godot. Useful if you want to emulate the look of old classics like Fallout 2, but with some extra features. Considering that my voice is not so nice, and my english pronounciation is even worse, I also added texts to help you underestand what Im saying. You will also notice some background noise, but cant do anything to solve that. Any suggestion is welcome. Expect another tutorial soon.... or sor tof. This time, will be about my AI system.

Testing animation retargeting in Godot 4

 We have finished the project and it is time tostart a new one. This time, I have convinced the team to work on a combat  prototype and try Godot 4. After a month, Im quite pleased with the progress. Specially, we have applied animation retargeting, which is a new feature in Godot 4. In previous project, our main artist devised a clever way to reuse animations, but now we have a native solution. Our first attemp didnt worked, but I found that remapping the armature starting by the feet solved the problem. Weird, isnt it? By the way, you can see the prototype here . WE are keeping it public to let people learn from our mistakes. And, if you need some animation retargeting tutorial, this is the guide we used: