Anyone idea why my animation isn’t playing on my Pickaxe? I had it working before but suddenly it just seems to want to do nothing. When i try the animation file on my object in inspector it clearly appears to be working just not in game.
I don’t know if “play automatically” in your Animation should be true if you want to start it via code.
Maybe you also should start to use the Animator System.
https://unity3d.com/learn/tutorials/modules/beginner/animation/animator-component?playlist=17099
And if the MineAnim is at the same GameObject like the Animation Component you don’t need the reference the GameObejct again. Just do something like.
public class MineAnim : MonoBehaviour {
private Animation myAnimation;
void Awake() {
myAnimation = GetComponent<Animation>();
}
void Update() {
if (Input.GetKeyDown(KeyCode.Space)) {
myAnimation.Play();
}
}
}
I put the code you posted onto my MineAnim script and the script is on my Pickaxe along with the animation. No errors but even still nothing is happening when i’m playing. I dunno what I’ve done here to break the animation :')
Try to get into Animator, it’s a newer system and you will maybe need it in your game

