Animation problem

07 June 2017 00:18
Hello again:

I've been trying to animate a character for a videogame and I have encountered an unexpected problem with the export. I have two separated blender files: one the scenery and other the character. I import the character to the main file (the scenery) as a dupligroup, similar to the Petigor setup. The animations work well in Blender and in the fast preview, too. They are skeletal animations, the setup for the bones is basically copied from the Petigor model. I have baked the animation and it keeps working well. But when I run the exported file in json the animated character gets completely messed up.

Another curious thing is that it deforms diferently depending which direction you are looking at. I´m getting to the point that I'm going to have to start from scratch as I think the scenery file has some problem I can't find.
Do anyone know which can be the problem? It is strange that the preview works ok and then the exported json does not.

I will be gateful with any suggestion.
07 June 2017 09:09
Are you able to export a good animation from the character file?
I wonder if you can reproduce the problem in a blank .blend file without your scenery.
If you can reproduce the problem in a file that you can upload, maybe we could get a better look at it.
07 June 2017 10:35
Another curious thing is that it deforms diferently depending which direction you are looking at. I´m getting to the point that I'm going to have to start from scratch as I think the scenery file has some problem I can't find.
Do anyone know which can be the problem? It is strange that the preview works ok and then the exported json does not.
Can you prepear a simple example with your charachter, so we can find the problem?
Blend4web and that kind of thing.
07 June 2017 11:36
Hi, thank you for the answers.

Today, I think I'm going to try starting a new main file and importing the character to see if it works in a new from scratch project. I think it must be something in the main file I have changed because in the fast preview the animation plays ok.

I will tell you the results.
08 June 2017 17:59
Hello again:

Well, I have created a new blender file and import the character without changing more than the lamp and camera types to work with the fps library (eye type for the camera). Imported the character from the other blender file and chage the javascript to load the new .json file. Everything loads ok but the result is the same, the character is completely messed up with the default animation activated. It is just a movement in one hand that is rigged with a inverse kinematics bone modifier. I don't know what can it be… The baking seems to be ok if I open the character file in the Scene Viewer so it is strange that it doesn't work with the exported .json. I don't know what to do now… Maybe I import the Petigor model and try to use the armature inside my app and start from there. It can be pretty tricky.

If someone can have a hint I'll be greatful.
08 June 2017 18:28
If someone can have a hint I'll be greatful.
Can you attach blend file with the problem? The only way to help you it's to study the file.
Blend4web and that kind of thing.
08 June 2017 18:58
If you want it the source is hosted in GitHub: . I don't know if you would like to branch it. Anyway, I am going to do a smaller version and upload it here, I am willing to get a hint of what is happening. I am very happy with the rest of it, it has a pretty nice environment, an island with palmtrees and a nice sea, some vegetation et al. I like the wind and the way you can control the time of day, very good. I hope I can find the solution to the animation problem so I don't get stucked.

I'll post the simplified example soon
09 June 2017 14:40
Hello again:

As I said, I have strip down the project to make it more manageable, now it has just a simple scene where I import the character with the animation.

Two things to say, I know the armature rig is minimal as I started a new armature when the one I had rigged started to mess up in the exported json/bin. Basically, the rig is the armature with just one arm rigged and one simple animation, moving left hand. If you open it in the fast preview it works ok, the scene doesn't have a light I remember, but you can see the animation working alright. If you open dev:project_ow.html is when the problem appears.

Aside, I have been studying the armature of the Petigor character and realized the original animations are kept in place with a fake user, today I am going to do some test to see if that is the problem as I just have the baked animation in the file.
10 June 2017 19:52
Right, at last I have found the problem, it was the way I was spawning the character. I had to import the whole Petigor model and animations into my island. Changed the init of the app to load the Petigor model and rig but animations didn't work at first, same problem, so I went to check the javascript, changed this:
var spawn_character = function(spawner_name) {
	var spawner = m_scs.get_object_by_name(spawner_name);
	var pos = m_trans.get_translation(spawner);
	m_trans.get_rotation(spawner, _quat);
	console.log("Spawner rotation: " + _quat);
	m_phy.set_transform(_char_wrapper.phys_body, [pos[0], pos[1], pos[2]], _quat);

And simply let the character at coordinates center. And animation started working. It is just:
exports.init_character = function() {
	_char_wrapper = {
		/**char_phys_body: m_scs.get_object_by_dupli_name("GroupCharacterJim", "Character"),
		char_model: m_scs.get_object_by_dupli_name("GroupCharacterJim", "CharModel"),*/
		char_offset: [0.0, -3.0, -0.85], //[0.0, 0.0, 0.0]
		phys_body: m_scs.get_first_character(),
        rig:    m_scs.get_object_by_dupli_name('petigor', 'petigor_armature'),
        model:   m_scs.get_object_by_dupli_name('petigor', 'petigor_model'),
	// I was adding the model to the physics body here, maybe it was here where it was failing
	// m_cons.append_stiff(_char_wrapper.body, _char_wrapper.phys_body, _char_wrapper.char_offset);	
	m_fps.enable_fps_controls(_char_wrapper.phys_body, null, move_cb);
       // This is when I was calling the spawn.
	// spawn_character("EmptySpawner1");
	m_anim.apply(_char_wrapper.rig, 'petigor_run');
    m_anim.set_behavior(_char_wrapper.rig, m_anim.AB_CYCLIC);;

Well, even now I am not sure what was what messed up the thing. Maybe it was the offset that I was applying in the spawner method (using the physics library) or the way I was attaching the model to the physics body with the stiff constraint. The problem was I wanted to see the model from behind to see the animation. I was thinking of doing it first person view but just wanted to see the animations as I was animating, sooooo dumb!!!! Well at least I have learn a bit about the animation system internals, now I know where all the animation things are….

I am just going to learn how you spawn the golems in Petigor's Tale and stay with your way of doing it. Hope it help some people too.

Un saludo
10 June 2017 20:52
Well, at last we can enjoy Petigor Goes To The Caribbean…

Just joking, It is a beggining I am gonna change the character tomorrow but for now…

If you want to see it live, without diffuse as I had some problem with the material…
Petigor goes to the beach
Please register or log in to leave a reply.