How can I fix 2d animation and convert it to horizontal and vertical axis,How can I fix 2d animation issues as well as convert it to Horizontal and Vertical axis
So I have a 2d sprite in a 3d environment, which means I've made Idle animations for each direction, but whenever I press two keys at once and let go of one of the keys, it freezes on the idle animation until I stop moving, which makes sense since it plays the Idle animation when letting go of the key. I'm just wondering how I would be able to fix that and also convert it over to horizontal and vertical axis so that it would be compatible with gamepad.
I'm also fairly new to scripting so I'm sorry if the script looks like an abomination.
public Animator anim;
// Use this for initialization
void Start () {
anim = GetComponent<Animator> ();
}
// Update is called once per frame
void Update ()
{
if (Input.GetKeyDown (KeyCode.S))
{
anim.Play ("Paul_WalkDOWN");
}
if (Input.GetKeyUp (KeyCode.S))
{
anim.Play ("Paul_IdleDOWN");
}
if (Input.GetKeyDown (KeyCode.D))
{
anim.Play ("Paul_WalkRIGHT");
}
if (Input.GetKeyUp (KeyCode.D))
{
anim.Play ("Paul_IdleRIGHT");
}
if (Input.GetKeyDown (KeyCode.A))
{
anim.Play ("Paul_WalkLEFT");
}
if (Input.GetKeyUp (KeyCode.A))
{
anim.Play ("Paul_IdleLEFT");
}
if (Input.GetKeyDown (KeyCode.W))
{
anim.Play ("Paul_WalkUP");
}
if (Input.GetKeyUp (KeyCode.W))
{
anim.Play ("Paul_IdleUP");
}
},
Your answer
![](https://koobas.hobune.stream/wayback/20220612161350im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Need advise with creating / outsourcing sprite sheets 2 Answers
What can make the camera position to display a sprite with bits of other frames. 1 Answer
Animation location problem! 0 Answers
Playing a sprite animation before an object is destroyed 0 Answers
Animated Tiles with using triggers (animating grass) 0 Answers