rigidybody.velocity doesn’t work anymore, they’d said that GetComponent().velocity works instead that, but doesn’t.
It works just fine here is an example.
using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
public class Jump : MonoBehaviour
{
public float jumpForce = 10f;
private bool isJumping;
private Rigidbody rb;
// Awake is called when the script instance is being loaded
void Awake()
{
rb = GetComponent<Rigidbody>();
}
// Update is called every frame, if the MonoBehaviour is enabled
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
isJumping = true;
}
}
// This function is called every fixed framerate frame, if the MonoBehaviour is enabled
void FixedUpdate()
{
if (isJumping)
{
rb.velocity = Vector3.up * jumpForce;
isJumping = false;
}
}
}