Question by
dharmender · Sep 12, 2015 at 05:46 PM ·
controllercontrollers
How to create dynamic animator controller (state machine, transtion etc) with .fbx files by using c# script
I want to create dynamic animator controller by using .fbx file. Let us suppose that I have lots of .fbx files which contains animations and more. Now, at runtime I want that some of the .fbx file must be used (Let say two i.e. Arm1.fbx and Arm2.fbx) to create a dynamjc controller, after that this controller will apply on Avatar. How to assign .fbx file to animator controller using c# script?
// code for that Animator animator; void Start () {
// Creates the controller
var controller = UnityEditor.Animations.AnimatorController.CreateAnimatorControllerAtPath ("Assets/DynamicController/MyController.controller");
Object ObjLoadController = AssetDatabase.LoadAssetAtPath("Assets/DynamicController/MyController.controller", (typeof(Object)));
// Loading fbx files from a folder
Object ObjLoadFbx = AssetDatabase.LoadAssetAtPath("Assets/fbxFromServer/Arms1.fbx", (typeof(Object)));
// Add parameters controller.AddParameter("TransitionNow",AnimatorControllerParameterType.Trigger);
// Add StateMachines var rootStateMachine = controller.layers[0].stateMachine; var stateMachineA = rootStateMachine.AddState("Arm1"); var stateMachineB = rootStateMachine.AddState("Arm2");
capture.png
(28.2 kB)
Comment
Your answer
