Exporting FBX files from Moho to Unity Issue

Discuss Moho bugs (or suspected bugs) with other users. To report bugs to Smith Micro, please visit support.smithmicro.com

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
ilovelessons
Posts: 52
Joined: Sat Dec 03, 2016 12:11 pm

Exporting FBX files from Moho to Unity Issue

Post by ilovelessons »

Hi Good day ,

I am having exporting FBX files into unity. I has asked the forum a few months ago but no one had the answer so I was hoping by now some one found the answer. Below is a description of the issue -

1. I made blinking eyes (using switch layers) and attached it to a BONE on a characters head in MOHO 12 Pro
2. The eyes blink when the head is moving in the FBX preview mode.
3. However when I export the FBX file and import it to Unity 5.0 the eyes do not blink.

Anyone out there every had this problem? Any suggestions... ?
the_royal_orchestra
Posts: 10
Joined: Tue Feb 14, 2017 1:24 am

Re: Exporting FBX files from Moho to Unity Issue

Post by the_royal_orchestra »

Hi,
can you post your .fbx file?
It seems like the fbx exporter does not support smart bones, but it does export animations made with the help of smart bones correctly, as far as I know.
To mimic the smart bone controlling the switch layers in Unity you have to write a script to make the bone smart again.
Mohos fbx exporter just scales inactive switch layer children down to 0.000001 and the active layer to 1.
It should not be so hard to do the same with a script in Unity.
But it is easier to animate in Moho I guess.

I wonder why the Moho programmers don't generate a c# -script for Unity automatically alongside the exported .fbx file to accomplish things which are obviously not supported by .fbx format.

Perhaps this helps also:
viewtopic.php?f=9&t=30600
ilovelessons
Posts: 52
Joined: Sat Dec 03, 2016 12:11 pm

Re: Exporting FBX files from Moho to Unity Issue

Post by ilovelessons »

Hi the_royal_orchestra,

Hi thank you very very very much for all the help. I began to read the link you sent, its a lot to take in but am trying. Also I uploaded my FBX file to the link below. Its a simple animation with a vampire and his eyes and mouth are suppose to be blinking and moving but when played in UNITY only the first child in the switch layer is shown.

Below is the link to the file

https://file.town/download/10cztz54ebhocbwasqnrr5gxv

If also the link does not work for whatever reason you can send your email and i'll email it to you or my email is iLoveLessons@gmail.com

Anyway thanks again mate.
the_royal_orchestra
Posts: 10
Joined: Tue Feb 14, 2017 1:24 am

Re: Exporting FBX files from Moho to Unity Issue

Post by the_royal_orchestra »

Hi,
I just had a look at the .fbx file in unity. I am not really sure what is going on, yet.
Could you also post your source Moho file, please?
best regards
ilovelessons
Posts: 52
Joined: Sat Dec 03, 2016 12:11 pm

Re: Exporting FBX files from Moho to Unity Issue

Post by ilovelessons »

Hi Royal_orchetsra,

Below is the link for all the Files (MOHO, FBX and Source Files)

https://file.town/download/gqbm10h2gvyy7bd1apn1r8ay0

thanks again
the_royal_orchestra
Posts: 10
Joined: Tue Feb 14, 2017 1:24 am

Re: Exporting FBX files from Moho to Unity Issue

Post by the_royal_orchestra »

Hah, think I found the problem.
If an animation in Moho uses Flexi-Binding on Switching-Layers Unity sees that this layer is affected by more than one bone and applies the Skinned-Mesh-Renderer to bend the mesh properly. This is okay. BUT it breaks Moho's FBX-Exporter's workaround of scaling layers down to make them invisible. This workaround only works with the MeshRenderer in Unity. Unity automatically chooses the Mesh-Renderer if you use layer binding in Moho.
To get your .FBX working I released the two Switching layers (Mouth and Eyes) from Flexi-Binding and bound both layers to the head bone using the bind layers tool. Thats it. Flexi-binding works good for the head and body.

Here is your example working with .moho, .fbx and the Unity project:
https://drive.google.com/open?id=0ByVfk ... 2V5LXNpOTg

This simple example proves that Moho's workaround with rescaling meshes to mimic switching layers is not reliable.
I am not sure if a Unity-script could fix this, to keep the workaround alive.

So: don't use Flexi-binding on switching layers.
best regards
Jens
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Exporting FBX files from Moho to Unity Issue

Post by synthsin75 »

the_royal_orchestra wrote:This simple example proves that Moho's workaround with rescaling meshes to mimic switching layers is not reliable.
I am not sure if a Unity-script could fix this, to keep the workaround alive.

So: don't use Flexi-binding on switching layers.
It's best practice to layer-bind switch layers anyway, since flexi-binding can cause undesired results, even just in Moho.
the_royal_orchestra
Posts: 10
Joined: Tue Feb 14, 2017 1:24 am

Re: Exporting FBX files from Moho to Unity Issue

Post by the_royal_orchestra »

Ok. Good to know!

I just did a test and its pretty easy to fix that in Unity. Here is a script to get skinned mesh rendered flexi-bound switching layers working and make vampires blink
Perhaps this is a better way of handling all MohoFBX switch layers in Unity anyway. I'll try.

Apply directly to the broken switching layer in Unity:
https://drive.google.com/open?id=0ByVfk ... nRPLUYzanM

switchLayerFix.cs

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class switchLayerFix : MonoBehaviour {

	// Use this for initialization
	void Start () {

	}
	
	// Update is called once per frame
	void Update () {

		int kids =	transform.childCount;

		for (int k=0; k < kids ; k ++){
			Transform kid = transform.GetComponentInChildren<Transform> ().GetChild(k);
			if (kid.localScale == new Vector3 (0.000001f, 0.000001f, 0.000001f)) {
				kid.gameObject.SetActive (false);
			} else { kid.gameObject.SetActive (true);
			}
		}


	}
}
Post Reply