public class PlayerInput : MonoBehaviour

{ย  ย public float speed = 8f;

ย  ย  public float jumpPower = 700f;


ย  ย  private int jumpCount = 0;

ย  ย  private Rigidbody2D playerRigidbody;

ย  ย  private Animator playerAnimator;


ย  ย  // Start is called before the first frame update

ย  ย  void Start()

ย  ย  {

ย  ย  ย  ย  playerRigidbody = GetComponent<Rigidbody2D>();

ย  ย  ย  ย  playerAnimator = GetComponent<Animator>();

ย  ย  }



// ํ•˜๋‹จ๋ถ€ํ„ด ํ‚ค ์ž…๋ ฅํ•˜๊ณ  ์ด๋™ ์ฒ˜๋ฆฌ

ย  ย  void FixedUpdate()

ย  ย  {

ย  ย  ย  ย  float xInput = Input.GetAxis("Horizontal");

ย  ย  ย  ย  float xSpeed = xInput * speed;

ย  ย  ย  ย  Vector2 updatedMovement = new Vector2(xSpeed, 0);

ย  ย  ย  ย  playerRigidbody.velocity = updatedMovement;


ย  ย  ย  ย  // ์ ํ”„ ํ‚ค ์ž…๋ ฅ์‹œ

ย  ย  ย  ย  if (Input.GetButtonDown("Fire1"))

ย  ย  ย  ย  {

ย  ย  ย  ย  ย  ย  playerRigidbody.AddForce(new Vector2(0f, jumpPower));


ย  ย  ย  ย  }

ย  ย  ย  ย  else if (Input.GetButtonUp("Fire1") && playerRigidbody.velocity.y > 0)

ย  ย  ย  ย  {

ย  ย  ย  ย  ย  ย  playerRigidbody.velocity = playerRigidbody.velocity * 0.5f;

ย  ย  ย  ย  }


ย  ย  }

}



์ฑ…์—์„œ ๋ฐฐ์šด๋Œ€๋กœ ์งœ ๋ดค๋Š”๋ฐ ์ž์—ฐ์Šค๋Ÿฌ์šด ์ ํ”„๊ฐ€ ์•„๋‹ˆ๋ผ ๊ฑ ์œ„์ชฝ์œผ๋กœ ์ˆœ๊ฐ„์ด๋™ ํ›„ ๋ฌผ์†์—์„œ์ฒ˜๋Ÿผ ๋А๋ฆฌ๊ฒŒ ํ•˜๊ฐ•ํ•จ...


์–ด๋–ค ๊ฑธ ๊ณ ์ณ์•ผ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ๋Š”์ง€ ๋„์›€ ๋ถ€ํƒ...