Multiple animation controllers?

Greetings, everyone.

I have no experience with animations. I am a programmer. I am working on recreating the crowd AI from red dead redemption. It works like this:

The AI decides what to do via an option stack, which includes things like goToMarket, goHome and inside of those; browseItems, buyItems etc. Most of these stacks require a unique animation.
Instead of making every AI remember their own set of animations, every AI only needs to keep track of their own basic animations ie. idle, walk, run, greet etc. The animations required by the stack is stored in the world. This saves alot of memory usage! So all animations related to the market is stored by the market itself.

Example: The AI decides that its a good idea to go to the market. It uses the walk animation when walking to the market. Once it enters the bounds of the market, a hotspot script will signal the AI and update its behaviour. Now the AI decides it needs to browse the market. It goes infront of a market stand. Now it needs to play the animation “browseItems”. The hotspot script has a refrence to all the animations needed, so it tells the AI what animation to play. Then the AI decides to buy an item, so it requests an animation for that, and the hotspot script provides the animation.

More examples: The AI is finished in the market, it decides to go to church. It leaves the market area, and therefor can no longer access its animations. It goes into the church area, and a new hotspot script greets it and shows it a refrence to all animations needed. The AI finds a seat. It plays a sit animation, then it plays a pray animation ontop of that sit animation. It finished and plays standup or sit in reverse. And then goes home. Once it leaves the church area, it can only use the basic animations (idle, walk, run, greet etc.)

So here is my problem. I don’t know how to do this animation wise. An animationcontroller stores multiple animations right? The AI has a controller with the basic animations, but it also needs to play animations from a seperate animation controller. How do I do this?

An AnimationController is just a state machine that has animation clips attached to each state. In the controller you can specify params like ints, floats, bools or triggers. For example you can create an idle state that plays your idle animation, and have another walk state that you can transition to by a trigger param, say “walk”. In script, you get a hold of your AIs Animator component, which holds the controller, and call SetTrigger(" walk") on it. So basically whatever existing animation state logic you have just needs to modify the params accordingly on the right Animator component’s controller.

1 Like

Put all your animations in one big animator controller, and assign that animator controller to all of your characters. An animator controller has references to animation clips. Those clips are loaded once and shared among all characters and controllers. The animation clips aren’t duplicated for each character, so you’re not saving memory.

2 Likes

Well, i see that this still an issue. It would be handy have a script to attach multiple animator controller that listen at different event. I know what you mean about the state machine, that means . even if you have multiple animator at the end they act as it was one. that could be a good strategy. isnt it?