using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class movement : MonoBehaviour
{
ย ย Rigidbody2D rb;
ย ย public float speed = 5f;
ย ย public float checkRadious;
ย ย private float jumpforce = 10f;
ย ย private float moveinput;
ย ย private bool isgrounded;
ย ย public Transform groundcheck;
ย ย public LayerMask whatisground;
ย ย // Start is called before the first frame update
ย ย void Start()
ย ย {
ย ย ย ย rb = GetComponent<Rigidbody2D>();
ย ย }
ย ย // Update is called once per frame
ย ย void Update()
ย ย {
ย ย ย ย isgrounded = Physics2D.OverlapCircle(groundcheck.position, checkRadious, whatisground);
ย ย ย ย if (Input.GetKeyDown(KeyCode.W) && isgrounded)
ย ย ย ย {
ย ย ย ย ย ย jump();
ย ย ย ย }
ย ย ย ย moveinput = Input.GetAxisRaw("Horizontal");
ย ย ย ย rb.velocity = new Vector2(moveinput * speed, rb.velocity.y);
ย ย }
ย ย void jump()
ย ย {
ย ย ย ย rb.velocity = Vector2.up * jumpforce;
ย ย }
}
์ ํ ๋๋๋ฐ? ๋ฌธ์ ๋ ์ด๊ฑฐ ๊ทธ๋ผ์ด๋์ฒดํฌ ์ด์ํ๋ค ์ผ๋ฐ์ ์ผ๋ก ์ด๋ ๊ฒ ์ฒดํฌ์ํ์์