вот сам код:
Скрытый текст:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerControl : MonoBehaviour
{
public float speed = 20f;
private Rigidbody2D rb;
Animator anim;
int TimeCount;
public GameObject RestartMenu;
private bool die = false;
private bool isGrounded;
public Transform groundCheck;
public float checkRadius;
public LayerMask whatIsGround;
void Start()
{
rb = GetComponent <Rigidbody2D> ();
anim = GetComponent<Animator> ();
}
private void FixedUpdate()
{
isGrounded = Physics2D.OverlapCircle(groundCheck.position, checkRadius, whatIsGround);
rb.velocity = new Vector2(speed, rb.velocity.y);
}
void Update()
{
if (die == true) {
speed = 0;
Invoke("Restart", 1);
}
if (Time.timeScale == 1f)
{
TimeCount++;
}
if (TimeCount == 2222)
{
speed++;
TimeCount = 0;
}
if(isGrounded == true && die == false){
anim.SetInteger("person", 2);}
else {anim.SetInteger("person", 1);}
if (Input.GetKey (KeyCode.Space) && die == false && Time.timeScale == 1f) {
anim.SetInteger("person", 3);
rb.AddForce (Vector2.up * 400);
}
if (die == true) {
anim.SetInteger("person", 4);
}
}
void OnCollisionEnter2D(Collision2D shit)
{
if (shit.gameObject.tag == "enemi")
{
die = true;
}
}
void Restart()
{
RestartMenu.SetActive(true);
Time.timeScale = 0f;
}
}
using System.Collections.Generic;
using UnityEngine;
public class PlayerControl : MonoBehaviour
{
public float speed = 20f;
private Rigidbody2D rb;
Animator anim;
int TimeCount;
public GameObject RestartMenu;
private bool die = false;
private bool isGrounded;
public Transform groundCheck;
public float checkRadius;
public LayerMask whatIsGround;
void Start()
{
rb = GetComponent <Rigidbody2D> ();
anim = GetComponent<Animator> ();
}
private void FixedUpdate()
{
isGrounded = Physics2D.OverlapCircle(groundCheck.position, checkRadius, whatIsGround);
rb.velocity = new Vector2(speed, rb.velocity.y);
}
void Update()
{
if (die == true) {
speed = 0;
Invoke("Restart", 1);
}
if (Time.timeScale == 1f)
{
TimeCount++;
}
if (TimeCount == 2222)
{
speed++;
TimeCount = 0;
}
if(isGrounded == true && die == false){
anim.SetInteger("person", 2);}
else {anim.SetInteger("person", 1);}
if (Input.GetKey (KeyCode.Space) && die == false && Time.timeScale == 1f) {
anim.SetInteger("person", 3);
rb.AddForce (Vector2.up * 400);
}
if (die == true) {
anim.SetInteger("person", 4);
}
}
void OnCollisionEnter2D(Collision2D shit)
{
if (shit.gameObject.tag == "enemi")
{
die = true;
}
}
void Restart()
{
RestartMenu.SetActive(true);
Time.timeScale = 0f;
}
}