c# - UnassignedReferenceException on an assigned variable (unity 3D) -
i'm new unity (using 4.5) , i'm trying learn unity 3d. have small "game" want swing axe kill spiders. have created animation named "axeswing" , small script trigger animation when click left button. probleme have error saying variable "attackanimationclip" has nothing assigned it. can see on screen shot assigned , when left click animation trigger , come idleaxe animation.
here script:
[requirecomponent(typeof(animation))] public class attackanimation : monobehaviour { public animationclip attackanimationclip; // update called once per frame void update () { if (input.getmousebutton(0)) animation.play(attackanimationclip.name); else if (isattackfinished) animation.crossfade(animation.clip.name); } private bool isattackfinished { { return animation[attackanimationclip.name].time > animation[attackanimationclip.name].length; } } }
since have animation attached gameobject can this:
animation.play("axeswing");
Comments
Post a Comment