I've been looking around for a while trying to figure out how to play simple animations with Unity via ONLY C# script, with no drag-and-drop involved. So far I've found various tutorials explaining how to manually set up a animation controller for each object, then manually select each animation state and manually create a transition then manually set the transition length to the most minimum possible etc...

I was wondering if there's a simple way to just do something like...

    "stand still /* which would be the name of the action state created in blender */", 

...WITHOUT creating an animation controller manually at all, I haven't been able to find any resource to do this simple thing yet.

  • \$\begingroup\$ Have you found out a way to solve your problem? \$\endgroup\$ – Sriram Nov 6 at 15:23
  • \$\begingroup\$ @Sriram mainly just using the almost deprecated version of the animation playing, the new GLTF unity extension uses it \$\endgroup\$ – bluejayke Nov 17 at 4:31

I would recommend using an animation controller if you will ever need to blend animations or do any kind of complicated state. If you don't want transitions, you don't have to add them, just call Animator.Play("state_name").

But, if you just want a simple way to play single animation clips, you might be interested in this blog. Unity created that exact component, and you can grab it from GitHub.

  • \$\begingroup\$ Hi U;m not exactly sure what :simple animation clips" is different than just playing an animation (AND transiting it to any other) but I jut want to make my point again: I have several models, each with compltely different animation Action sequences in blender, and when imprting to unity, I don't want to use the UI at ALL in any way, everything has to be done with only code, so I'm not entirely sure if this answers the question, but: How do I simply play any animation AND transition any animation to any other animation, just with only the model data, without usign unities UI at all? \$\endgroup\$ – bluejayke Oct 15 '18 at 0:24
  • \$\begingroup\$ and regarding the first part of the answer again, I'm not trying to play animation "states" Im just trying to play the built in animation from the model itself, and I don't want to manually make any "states"a t all so IDK if theres a way to generate all states with C# \$\endgroup\$ – bluejayke Oct 15 '18 at 0:25
  • \$\begingroup\$ If you expand your imported blend file, you will see meshes and animations imported as separate assets. Your MeshRenderer doesn't know about animation data, and your animation data doesn't know about your mesh, so what you are trying to do does not make much sense within the context of Unity. Try learning Unity's animation system, It will only take a few minutes to set up an animation controller once you are used to the system. Just drag and drop your animation clips onto the controller to generate states. \$\endgroup\$ – Kokkivos Oct 15 '18 at 20:48
  • \$\begingroup\$ @Kokkvios thanks, I hear what your saying "Unitys' animation system is not hhard, just use it!" thanks, but lets say, theoretically, I had 1000 different models, each model has different animation data set up completely differently in blender lets say, and when I import those models into unity, I just want to import them all at once, and simply call a bit of script that says "model.PlayAnimation('walk', 'loop')" or something, WITHOUT any prior setup. Just think practically: the same proble could be if you're loading in the models from a romate server where yuo cAN"t manually drag things!? \$\endgroup\$ – bluejayke Oct 16 '18 at 4:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.