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

public class Mover : MonoBehaviour {

    public float speed = 10;
    public Vector3 velocidad;
    [SerializeField]
    private int _angles = 45;
    

    private void Start()
    {
        transform.rotation = Quaternion.Euler(new Vector3(-90, 0, -180));

    }
    // Update is called once per frame
    void Update()
    {
        
        
    }

    void FixedUpdate()
    {
        float h = Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");
        Debug.Log("Horizontal Input : " + h + "Vertical Input : " + v);

        velocidad = new Vector3(h, 0, v);

        transform.position += (new Vector3(h, 0, v).normalized) * Time.deltaTime * speed;        
        //transform.rotation = Quaternion.Euler(new Vector3(0, 0, 90));


         
        if (v == 0 && h == 0)
        {
            Debug.Log("Salto");
        }

        //SE
        else if ((v < -0.5f) && (h > 0.5f))
        {
            Debug.Log("SE");
            transform.rotation = Quaternion.Euler(new Vector3(-90, 0, 135));
        }

        //SO
        else if ((v < -0.5f) && (h < -0.5f))
        {
            Debug.Log("SO");
            transform.rotation = Quaternion.Euler(new Vector3(-90, 0, -135));
        }

        
        //NE
        else if ((v > 0.5f) && (h > 0.5f))
        {
            Debug.Log("NE");
            transform.rotation = Quaternion.Euler(new Vector3(-90, 0, 45));
        }

        //NO
        else if((v > 0.5f) && (h < -0.5f))
        {
            Debug.Log("NO");
            transform.rotation = Quaternion.Euler(new Vector3(-90, 0, -45));
        }
        
        //O
        else if (h < -0.5f)
        {
            transform.rotation = Quaternion.Euler(new Vector3(-90, 0, -90));
        }

        //E
       else if (h > 0.5f)
        {
            transform.rotation = Quaternion.Euler(new Vector3(-90, 0, 90));
        }

        //S
        else if (v < -0.5f)
        {
            transform.rotation = Quaternion.Euler(new Vector3(-90, 0, -180));
        }

        //N
        else if (v > 0.5f)
        {
            transform.rotation = Quaternion.Euler(new Vector3(-90, 0, 0));
        }        






    }
}
