How to assign mesh with animation to gameobject?

What I want to do:

  • I want to assign animated mesh to empty GameObject using script only.
  • I am using Resources folder. No drag and drop properties.

Could you please point out things I need to do? (I don’t need whole code, just few points explaining what needs to be done)

Subquestions:
Would it be possible to control animation speed from component on that gameobject?
Would it be possible to set animation’s current frame/time?

Why the heck am I not using prefabs?
Basically I need to solve my problem by inheritance. It’s way cleaner solution (Even when it doesn’t sound like it, but trust me) that trying to figure out this procedural hell using standard unity practices.

Ok, so I figured out I would need to:

  1. Add animator component to my gameobject
  2. Add skinned mesh component
  3. Somehow add bones

I thought bones are also something like component or material, not whole new set of gameobjects, so my current way of doing things is not ideal. Back to the drawing board… :slight_smile:

I have no idea what you’re talking about here, but have you considered making a prefab for only the animated mesh objects. That way you could “use inheritance” in your own components, but then just attach the prefab as a child object. You don’t necessarily need to make your entire character from a prefab.

1 Like