- Home /
Question by
Shrimpkicker · Mar 18, 2016 at 12:25 PM ·
animation2d
How would one make an animation play in the 2D engine with the press of a button?
Hey guys. I'm working in the 2D unity engine. I'm trying to animate a character in the game, where the walk animation plays when the player presses a button. I have followed many tutorials for animating with similar problems, but I have a problem with my scripting. My current script is as follows:
using UnityEngine;
using System.Collections;
public class walk_animation : MonoBehaviour {
void Update()
{
if (Input.GetKeyDown(KeyCode.W))
{
animation.Play("Walking", PlayMode.StopAll);
}
}
}
There is an error on the "animation.Play" command. Does anyone know a solution?
Comment
Your answer

Follow this Question
Related Questions
2D Animation does not start 1 Answer
Can I make animations snap to a frame? 1 Answer
Sprite rotation with animation (2d project) 0 Answers
How to play correct animation based on 2d movement? 3 Answers