Prefab animations keeps teasing me
Help. I'm going nuts here. I have fixed the problem, but in a very stupid way, but couldn't find a better way. It's do-able at this moment, but if I ever end up in a position like this again I would love to know a better way of handling this problem:
First I created a GameObject (Let's call it Banana) and added all the needed scripts and everything. Also added an animation called IdleBanana. When everything was set up I added this one to prefabs for easy grabbing later Now I needed to create another prefab that was 90% the same as this one (only animation and a few properties was different), so I came up with the brilliant idea: Let's just duplicate the Banana prefab, rename it to Carrot, change the needed properties and drag the Carrot into the scene to change the animation of the Carrot So I played a bit around with the animator by creating a new animation called IdleCarrot and did the animation. In the animator for Carrot I removed the old animation IdleBanana
Here I thought that everything was just perfect. I would now have a Banana prefab with the IdleBanana animation and I would have a Carrot prefab with the IdleCarrot animation. Right? Nope, very very wrong. My Banana prefab now has the IdleCarrot animation
I then tried to pull the Banana prefab into the scene again so I could fix the animation (arrrggg, why can't I easily load an animation into an objects animation). Created the IdleBanana animation again and then in the end realize that my Carrot now had the IdleBanana animation instead of the IdleCarrot
With other words: If I duplicate a prefab, the duplicate and the original are forever bound together. Very annoying
The way I "fixed" it was pretty much by starting over. To be on the safe side I deleted both prefabs, created two new GameObjects in the scene (one for each) and recreated them from scratch one by one. Then at the end I added them as prefabs one by one, so they would not be connected in any way Currently it was do-able as it was simple GameObjects with simple scripts and simple animations, but had it been more advanced I would have gone nuts
What would be the best way to handle a situation like this? Where I have one prefab I would like to duplicate (without any connection to the original) so I wouldn't have to create a new prefab from scratch?
Answer by IgorAherne · Mar 13, 2017 at 01:10 AM
google nested prefabs
Thanks, did not know what it was called
Unfortunately after doing a bit of Googling I'm still as confused as before. Everything I have found so far tells me that nested prefabs is not possible in Unity, which is a bit weird considering that my problem seems to be that my prefabs are nested somehow? Or am I missing something? Everybody seems to complain that they can't do what I did, while I'm trying to avoid doing it
I also came across this page: http://devmag.org.za/2012/07/12/50-tips-for-working-with-unity-best-practices/ In tip 20 they tell me to do what I did to have a backup of a prefab, but from my experience this is a very bad tip, considering that the backup and the original prefab are linked together. Changing one of them will change both and if you end up with one messed up prefab, you will now have two messed up prefabs as the backup is also messed up
Your answer
Follow this Question
Related Questions
Multiple animations on the same GameObject won't work 0 Answers
Play random animation on an instantiated prefab 0 Answers
Animations created in Runtime 0 Answers
How can I animate my 3D object without affecting the physics? 0 Answers
Should I make completely new animation and animator for every new lift I will create? 1 Answer