How to make a lot of simple interaction that triggers a lot of animations?

Hello everyone!

I got a question.

I want to make a game where you walk in a building and you can interact with a lot of objects.
Lets say I have a room with a few objects like a trashcan, door, few bookcases etc.
I want to make them play an animation when I have my mouse on them (hover maye?)
and then press E button on my keyboard, and when i do, then the object that I have my mouse on plays an animation, and stays on the end (like open a chest, and the chest stays open, and to close I have to press E again on the chest.)
(something like an RPG game)
I am making an RPG game by the way, if that is needed to know to help solve this problem.

How can I script it the best way?
And how do I assemble the animator the best?

Thank you all in advance,

Daniel Nowak Janssen.

One way you could do it:

Each object needs an animator controller of it’s own that will function as it’s state machine. the animator controller will contain boolean variables that will control which animation gets played when the object is interacted with.