Вид збоку

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class Controll : MonoBehaviour

{

     public float jumpForce = 6000f;

     bool inAir = false;

     public float speed = 10f;

     private float moveInput;

     private Rigidbody2D rb;


     void OnCollisionEnter2D(Collision2D collision)

     {     

          inAir = false;

     }

  

     void Start()

     {

          rb = GetComponent<Rigidbody2D>();

     }


     void FixedUpdate()

     {

          moveInput = Input.GetAxis("Horizontal");

          rb.velocity = new Vector2(moveInput * speed, rb.velocity.y);


          if (Input.GetKeyDown("space")  && !inAir){

               rb.AddForce(Vector2.up * jumpForce * Time.deltaTime);

               inAir = true;

   } 

     }

}