Playing animation while moving vertically and horizontally

Hey everyone, i’m trying to play a running animation on my mesh when Input.GetAxis(Horizontal) or Input.GetAxis(Vertical) is true. I watched a Youtube video but they only made the animation play when Input.GetAxis(Vertical) is true, now my animation only plays when the “a” key is pressed. How do i make it so that the animation plays when any of the “wasd” keys are pressed using the animator and scripting?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour {

    //The speed of the player.
    public float playerSpeed;

    private float vert;

    public Animator playerAnim;

    void Start ()
    {
        playerAnim = GetComponent<Animator>();
    }

    void Update ()
    {
        //The movement of the player.
        transform.Translate(Input.GetAxis("Horizontal") * playerSpeed * Time.deltaTime, 0f,
            Input.GetAxis("Vertical") * playerSpeed * Time.deltaTime);

        //Plays the "run" animation while the wasd keys are pressed.
        vert = Input.GetAxis("Vertical");
        playerAnim.SetFloat("run", vert);
    }
}

Your mecanim is probably checking the vert float that you are setting with SetFloat. Just do:

horizontal = Input.GetAxis("Horizontal");

Send the horizontal into your mecanim and have your mecanim also do the animation if horizontal changes as well.

I don’t really understand. Should i make a variable called horizontal? and how do i send it to my mecanim?