using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ваше название скрипта : MonoBehaviour
{
public float speed;
public float jumpForce;
protected bool doJump = false;
public Rigidbody2D rb;
// Start is called before the first frame update
void FixedUpdate()
{
if(doJump)
{
rb.AddForce(Vector3.up * jumpspeed, ForceMode2D.Impulse);
doJump = false;
}
}
// Update is called once per frame
void Update()
{
transform.Translate(Vector3.right * speed);
if(Input.GetKeyDown("space"))
{
doJump = true;
}
}
}