(Unity)How to make an animation for hundreds of figures(very similar in appearance) in one time?

Viewed 27

I'm creating a restaurant mobile game and it will have hundreds of customers who are very similar in appearance.(ex:just hairstyle,hair color, clothes color different.)

Is there any method to create their animations(ex: walking) in one time without repetitive procedure?

2 Answers

There is no way to do that. You have to do it for each character individually.

Assuming all your characters use the same Animator Controller, you can set a default animation to use within that controller.

Otherwise, no, there is no "Apply animation to all" command available.

You can accomplish essentially the same task with scripting. Apply a script to all your characters, like a "MyAnimation" script, and within that script's Update loop watch for changes to a static variable. Then when you change the value of that variable, have each character update their animation accordingly. I don't think that's necessarily the best way to do it, but it is a pretty quick way.

public class MyAnimation: MonoBehaviour
{
    Animator _animator = null;

    public static string AllAnimationsName = null;

    string _lastAnimationName = null;
    
    void Start()
    {
        _animator = GetComponent<Animator>();
    }
    void Update()
    {
        if (_lastAnimationName != AllAnimationsName)
        {
             _lastAnimationName = AllAnimationsName;
             //TODO:: Apply the animation to the characters animator such as:
             //_animator.CrossFade(_lastAnimationName);
        }
    }
}

Again, not the best way to do it but it should allow you to quickly control all the characters with the script applied to them without iterating through each.

Related