I have attached some screenshots so you can see how I have achieved this:
this is the character I am working with>>>screenshot_2
this is my animator>>>>>screenshot_1
this is my blend tree in the idle state>>>>>screenshot_3
and so far,this is my script:
using UnityEngine;using System.Collections;public class PlayerDirectionAndShooting : MonoBehaviour {Rigidbody2D rbody;Animator anim;// Use this for initializationvoid Start () {rbody = GetComponent<Rigidbody2D> ();anim = GetComponent<Animator> ();}// Update is called once per framevoid Update () {Vector2 direction_vector = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));anim.SetFloat("input_x", direction_vector.x);anim.SetFloat("input_y", direction_vector.y);if (Input.GetKeyDown("space")){if (anim.GetFloat("input_x") <= -1){anim.SetBool("is_shooting_left", true);}}else{anim.SetBool("is_shooting_left", false);};if (Input.GetKeyDown("space")){if (anim.GetFloat("input_y") <= -1){anim.SetBool("is_shooting_down", true);}}else{anim.SetBool("is_shooting_down", false);};if (Input.GetKeyDown("space")){if (anim.GetFloat("input_y") <= 1){anim.SetBool("is_shooting_up", true);}}else{anim.SetBool("is_shooting_up", false);};if (Input.GetKeyDown("space")){if (anim.GetFloat("input_x") <= 1){anim.SetBool("is_shooting_right", true);}}else{anim.SetBool("is_shooting_right",false);};}}