using System.
Collections;
using [Link];
using [Link];
using [Link];
using UnityEngine;
public class PlayerMove : MonoBehaviour
{
public float speed;
public float jumpForce;
private bool isJumping;
private float move;
[SerializeField] private LayerMask layerGround;
Rigidbody2D rb;
Animator anim;
SpriteRenderer spR;
BoxCollider2D bxC2D;
void Start()
{
rb = GetComponent<Rigidbody2D>();
anim = GetComponent<Animator>();
spR = GetComponent<SpriteRenderer>();
bxC2D = GetComponent<BoxCollider2D>();
}
// Update is called once per frame
void Update()
{
Move();
Jump();
}
void Move()
{
move = [Link]("Horizontal");
[Link] = new Vector2(move * speed, [Link].y);
if(move > 0)
{
[Link]("Run", true);
[Link] = false;
}
if(move < 0)
{
[Link]("Run", true);
[Link] = true;
}
if(move == 0)
{
[Link]("Run", false);
}
}
void Jump()
{
if([Link]("Jump"))
{
if(!isJumping)
{
[Link](new Vector2(0f, jumpForce), [Link]);
}
}
if([Link].y > jumpForce)
{
[Link] = [Link] * jumpForce;
}
if(isGrounded())
{
isJumping = false;
}
else
{
isJumping = true;
}
}
private bool isGrounded()
{
RaycastHit2D ground = [Link]([Link],
[Link], 0, [Link], 0.1f, layerGround);
return [Link] !=null;
}
}