Я пытаюсь добавить двойной прыжок к своему плееру, но у меня есть эта ошибка
, и у меня возникают проблемы с фигурными скобками, потому что в запросе кода должен содержаться = открытый класс PlayerController: MonoBehaviour {ив конце}
код такой, если кто-то, кто видит это, знает C # и может помочь вам поблагодарить
using System.Collections;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public float moveSpeed;
private float moveSpeedStore;
public float speedMultiplier;
public float speedIncreaseMilestone;
private float speedIncreaseMilestoneStore;
private float speedMilestoneCount;
private float speedMilestoneCountStore;
public float jumpForce;
public float jumpTime;
private float jumpTimeCounter;
private Rigidbody2D myRigidbody;
private bool canDoubleJump;
public bool grounded;
public LayerMask whatIsGround;
public Transform groundCheck;
public float groundCheckSize;
private Collider2D myCollider;
private Animator myAnimator;
private bool stoppedJumping;
public GameManeger theGameManeger;
void Start()
{
myRigidbody = GetComponent<Rigidbody2D>();
myCollider = GetComponent<Collider2D>();
myAnimator = GetComponent<Animator>();
jumpTimeCounter = jumpTime;
speedMilestoneCount = speedIncreaseMilestone;
moveSpeedStore = moveSpeed;
speedMilestoneCountStore = speedMilestoneCount;
speedIncreaseMilestoneStore = speedIncreaseMilestone;
stoppedJumping = true;
}
void Update()
{
//grounded = Physics2D.IsTouchingLayers(myCollider, whatIsGround);
grounded = Physics2D.OverlapCircle(groundCheck.position, groundCheckSize, whatIsGround);
if (transform.position.x > speedMilestoneCount)
{
speedMilestoneCount += speedIncreaseMilestone;
speedIncreaseMilestone = speedIncreaseMilestone * speedMultiplier;
moveSpeed = moveSpeed * speedMultiplier;
}
myRigidbody.velocity = new Vector2(moveSpeed, myRigidbody.velocity.y);
if (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0))
{
if (grounded)
{
myRigidbody.velocity = new Vector2(myRigidbody.velocity.x, jumpForce);
stoppedJumping = false;
}
}
if (Input.GetKey(KeyCode.Space) || Input.GetMouseButton(0) && !stoppedJumping)
{
if (jumpTimeCounter > 0)
{
myRigidbody.velocity = new Vector2(myRigidbody.velocity.x, jumpForce);
jumpTimeCounter -= Time.deltaTime;
}
if (!grounded && canDoubleJump)
{
myRigidbody.velocity = new Vector2(myRigidbody.velocity.x, jumpForce);
stoppedJumping = false;
canDoubleJump = false;
}
}
if (Input.GetKeyUp(KeyCode.Space) || Input.GetMouseButtonUp(0))
{
jumpTimeCounter = 0;
stoppedJumping = true;
}
if (grounded)
{
jumpTimeCounter = jumpTime;
canDoubleJump = true;
}
myAnimator.SetFloat("Speed", myRigidbody.velocity.x);
myAnimator.SetBool("Grounded", grounded);
}
}
void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.tag == "killbox")
{
theGameManeger.RestartGame();
moveSpeed = moveSpeedStore;
speedMilestoneCount = speedMilestoneCountStore;
speedIncreaseMilestone = speedIncreaseMilestoneStore;
}
}
}
``````