//jak to naprawić? ponieważ kod mi się nie kompiluje
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class move : MonoBehaviour
{
public float moveSpeed;
public float jumpForce;
public KeyCode Left;
public KeyCode Right;
public KeyCode Jump;
private Rigidbody2D theRB;
public Transform Player;
public Transform GroundCheckPoint;
public bool isGrounded;
public float groundCeckRadius;
public LayerMask WhatisGround;
private float jumpTimerCounter;
public float jumpTime;
public bool isJumping;
void Start()
{
theRB = GrtComponent<Rigitbody2D>();
}
void Update()
{
isGroundedGrounded = Physic2D.OverlapCircle(GroundCheckPoint.position, groundCheckRadius, WhatisGround);
if(Input.GetKey(Left))
{
theRB.velocity = new Vector2(-moveSpeed, theRB.velocity.y);
}
else if(Input.GetKey(Right))
{
theRB.velocity = new Vector2(moveSpeed, theRB.velocity.y);
}
else
{
theRB.velocity = new Vector2(0, theRB.velocity.y);
}
if(Input.GetKeyDown(Jump) && isGrounded )
{
isJumping = true;
theRB.velocity = new Vector2(theRB.velocity.x, jumpForce);
jumpTimerCounter = jumpTime;
}
if (Input.GetKey(Jump) && isJumping == true)
{
if(jumpTimerCounter > 0)
{
theRB.velocity = new Vector2(theRB.velocity.x, jumpForce);
}
jumpTimerCounter = Time.deltaTime;
}
else
{
isJumping = false;
}
if(Input.GetKeyUp(Jump))
{
isJumping = false;
}
}
}