이건 게임 버튼을 누르면 지혼자 점프하다가 스크립트 창을 누르면 또 괜찮아짐 게임 창으로만 가면 지혼자 점프하고 난리가 남

밑에는 캐릭터 코딩한거 있음

점프 관련 코딩한거는  이 사람꺼 보고 했음 

제발 도와주세요 ㅠㅠ

https://www.youtube.com/watch?v=lghplYxN7u8&t=7s





여기는 타일맵 설정 어떻게 돼있는지 나와있음



요기는 캐릭터 설정? 스크립트? 암튼 그런거 있음











using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class Player_Move : MonoBehaviour

{

   //Max Speed

    public float maxspeed;

    //JUmpPower

    public float jumppoewer;

    //Jump

    [SerializeField]

    Transform pos; //캐릭터 밑에 점프인지 아닌지 알려주는 작은 동그라미 (중심점)

   

    [SerializeField]

    float checkradius; //반지름   이라고 하는데 잘 모름 시발 영상을 더 봐야할 듯


    [SerializeField]

    LayerMask islayer;


    

    //유니티 자체에서 데려온 애들

    Rigidbody2D rigid;

    SpriteRenderer spriterenderer;

    Animator anime;



    bool isGround;


    

    void Awake()

    {

        rigid = GetComponent<Rigidbody2D>();

        spriterenderer = GetComponent<SpriteRenderer>();

        anime = GetComponent<Animator>();

    }



   void Update()

    {

       //점프

        if (isGround == true && Input.GetButtonDown("Jump"))

            rigid.AddForce(Vector2.up * jumppoewer, ForceMode2D.Impulse);

        isGround = Physics2D.OverlapCircle(pos.position, checkradius, islayer);


       //좌우반전 코드

        if (Input.GetButton("Horizontal"))

            spriterenderer.flipX = Input.GetAxisRaw("Horizontal") == -1;


       //walking animation

        if (rigid.velocity.normalized.x == 0)

            anime.SetBool("isWalking", false);

        

        else anime.SetBool("isWalking", true);



        if (Input.GetButtonUp("Horizontal"))

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




    }


    void FixedUpdate()

    {

        //Player Move X

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

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


        if (rigid.velocity.x > maxspeed)  //Right MaxSpeed

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

        else if (rigid.velocity.x < maxspeed * (-1)) //Left MaxSpeed

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



        //Ray 

        Debug.DrawRay(rigid.position, Vector3.down, new Color(0, 1, 0));

        

        RaycastHit2D rayhit = Physics2D.Raycast(rigid.position, Vector3.down, 1, LayerMask.GetMask("TileMap"));


        if(rayhit.collider != null)

        {

            //if (rayhit.distance < 0.5f)

                //Debug.Log(rayhit.collider.name);

        }

    }






    

}