Не получается сделать прыжок в Unity
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
public class movement : MonoBehaviour
{
public float ff = 2000f;
public float sf = 500f;
public float jump = 30f;
public bool cubeGround = true;
public Rigidbody rb;
void FixedUpdate()
{
rb.AddForce(0, 0, ff * Time.deltaTime);
if (Input.GetKey("d"))
{
rb.AddForce(sf * Time.deltaTime, 0,0, ForceMode.VelocityChange);
}
if (Input.GetKey("a"))
{
rb.AddForce(-sf * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
}
if (Input.GetKey("w"))
{
rb.AddForce(0, 0, sf * Time.deltaTime, ForceMode.VelocityChange);
}
if(Input.GetButtonDown("Jump") && cubeGround)
{
rb.AddForce(0, jump * Time.deltaTime, 0, ForceMode.VelocityChange);
cubeGround = false;
}
}
void OnCollisionEnter(Collision cinform)
{
if (cinform.gameObject.tag == "ground")
{
cubeGround = true;
}
}
}
Я правда перепробовала всё, но игрок либо прыгает по воздуху, либо прыжок не работает в принципе (пересмотрела уже кучу гайдов, все равно не поняла)