using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class PlayerMove : MonoBehaviour

{

    public float maxSpeed;

    Rigidbody2D rigid;

    SpriteRenderer spriteRenderer;

    Animator anim;


    void Awake()

    {

        rigid = GetComponent();

        spriteRenderer = GetComponent();

        anim = GetComponent();

    }


    void Update()

    {

        //Stop Speed

        if(Input.GetButtonUp("Horizontal"))

        {   

            rigid.velocity = new Vector2(rigid.velocity.normalized.x * 0.5f, rigid.velocity.y);

        }


        //Direction sprite

        if(Input.GetButtonDown("Horizontal"))

             spriteRenderer.flipX = Input.GetAxisRaw("Horizontal") == 1;


        //Animation

        if (Mathf.Abs(rigid.velocity.x)

            anim.SetBool("Run", false);

        else

            anim.SetBool("Run", true);

    }


    void FixedUpdate()

    {

        //Move Speed

        float h = Input.GetAxisRaw("Horizontal");

        rigid.AddForce(Vector2.right * h, ForceMode2D.Impulse);


        //Max Speed

        if (rigid.velocity.x > maxSpeed) //Right Max Speed

            rigid.velocity = new Vector2(maxSpeed, rigid.velocity.y);

        else if (rigid.velocity.x

            rigid.velocity = new Vector2(maxSpeed * (-1), rigid.velocity.y);

    }

}


지금 걸어놓은 명령언데

어디가 문제여서 방향지정이 제대로 안되는걸까