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

public class Character : MonoBehaviour
{
    [SerializeField] Animator myAnimator;
    [SerializeField] Rigidbody2D myRigidbody;
    [SerializeField] float mySpeed;

    // Start is called before the first frame update
    void Start()
    {
        
    }

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

    void Hit()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            myAnimator.SetTrigger("Hit");
        }

    }

    void Move()
    {
        myAnimator.SetFloat("Walk", Input.GetAxis("Horizontal"));
        Vector2 movement = new Vector2(Input.GetAxis("Horizontal")*mySpeed, myRigidbody.velocity.y);
        myRigidbody.velocity = movement;
 
    }
}
