Exchange object in hierarchy with Animation

I am not sure if and how this can be remedied.

I have a animation imported from a unity package which belongs to a switch.
The Switch is a object with a hierarchy. The topmost Switch object has the animation component with a Animation Controller attached, and provides motion for the Underlying objects.






In my interaction the original Pin is “broken” and I have to replace it with a new one. So the scripted interaction removes the Pin Gamobject from the hierarchy and inserts in its place a new instanced object which has the same name and sits at the same position in the Hierarchy (but has a slightly different mesh).
This exchange results that the animation does not play on the newly created object.

For testing purposes I removed from the hierarchy and re-inserted the original “broken” one, and it continued to play the animation.
But when I duplicated the original “broken” object, removed the original and inserted the duplicate it did not play.

Its as if the animation plays only with this specific GameObject which was part of the model on import.

Hope you can help me out.Otherwise I will have to rethink how I can do this.

Thanks in advance

I did not found a way around this.
It looks that if you create an animation clip using Animation then it works only when the underlying objects stay the same and dont change.

I reverted to create motion at runtime.