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

public class playermovment : MonoBehaviour
{

    public CharacterController2D controller;
    public Animator animator;
    public GameObject Player;

    float horizontalMove = 0f;
    public float runSpeed = 40f;

    bool jump = false;
    bool crouch = false;

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

        horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;

        animator.SetFloat("Speed", Mathf.Abs(horizontalMove));

        if (Input.GetButtonDown("Jump"))
        {
            jump = true;
            animator.SetBool("IsJumping", true);
            // Yes he is suposed to be upside down :)

        }
    }

    public void OnLanding ()
    {
        animator.SetBool("IsJumping", false);

    }

    void FixedUpdate ()
    {

        controller.Move(horizontalMove * Time.fixedDeltaTime, crouch, jump);

        jump = false;


    }

}
