- Home /
Question by
BrandMusic · Jan 10, 2014 at 02:27 AM ·
animationbeginner
Why Won't My Animation Work?
Hi, I'm new to Unity and haven't been able to find anything online related to this issue. I'm trying to get my sword to swing with a basic animation made in unity when I click the left mouse button, but for some reason the animation plays as it should, but only once when I enter the game view and it isn't called when I click the left mouse button as it should. Here is what i'm working with with the code to the right. (The error at the bottom should be solved already) l
unitycommunityq1.png
(332.3 kB)
Comment
Best Answer
Answer by VioKyma · Jan 10, 2014 at 02:55 AM
From what I can see, your Sword variable is a Transform object. The animation will reside on the game object itself. Try using:
Sword.parent.animation.Play("MeleeAttack");
Thanks, this worked once I made the animation legacy as well
Your answer
![](https://koobas.hobune.stream/wayback/20220613130008im_/https://answers.unity.com/themes/thub/images/avi.jpg)