- Home /
Question by
mexey · Apr 07, 2014 at 05:08 PM ·
c#animation2dinstantiatemissingcomponentexception
Animation of Instantiated objects trouble
Something strange going on with the instantiation of animated objects(2d). My prefab have only two animation states: "idle" and "dead".
pos = new Vector3 (-5, 4, 0) * TileSize;
newObject = Instantiate (Bonus, pos, Quaternion.identity) as GameObject;
//This code creates an object, but "dead" animation doesn't start when needed.
pos = new Vector3 (-5, 4, 0) * TileSize;
newObject = Instantiate (Bonus, pos, Quaternion.identity) as GameObject;
newObject.animation.enabled=true;
//Creates an object and animation work well, but it gives me exception:
MissingComponentException: There is no 'Animation' attached to the "BonusBlock(Clone)" game object, but a script is trying to access it. You probably need to add a Animation to the game object "BonusBlock(Clone)". Or your script needs to check if the component is attached before using it.
Can anyone explain this? If 3rd string can't find the 'Animation' component, why everything works?
Comment