-1

I'm not an expert at unity, so bear with me. I want to load a 3D model and apply an animation to it at runtime by using the file path. They are both FBX files and I've already been able to load the 3D model in the scene using an FBXImporter in the following code.

public GameObject Eve;
GameObject fbx;
public static string fbxPath = /*File path*/;

// Start is called before the first frame update
void Start()
{
    if (File.Exists(fbxPath))
    {
        fbx = ModelImporter.Importer.Import(fbxPath); //Loads the 3D model from the fbx file and makes it a gameObject
        fbx.transform.parent = Eve.transform; //parenting that gameObect
    }
}

Now I just need to apply the animation from the other fbx file to it but I do not know how to do that. Any Help?

ps. In case you want to replicate it, I got the FBXImporter from this link: https://github.com/yuen33/FBXImporter and I got both the 3d model and animation from mixamo.

derHugo
  • 83,094
  • 9
  • 75
  • 115

1 Answers1

0

First of all simply run it in the editor and then check in the hierarchy what components are on your imported model.

  • If there is no Animator or Animation component anywhere then your importer doesn't support them at all.

  • If there is an Animator checkout the AnimatorController of it. There should be states you can switch to via Animator.Play providing according state name.

  • Or if it is an Animation component you will find a list of clips you can simply Animation.Play


Edit I just tested with this and this model and your importer doesn't seem to support animations ;)

derHugo
  • 83,094
  • 9
  • 75
  • 115