Use code tags:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class player : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Space) == true)
{
GetComponent<Rigidbody>().AddForce(Vector3.up * 5, ForceMode.VelocityChange);
}
}
}
And agreed w/ @CodeSmile , what do you mean by “didn’t work”? Didn’t work how?
Did you get an error? Did it not behave the way you anticipate? What did you anticipate? Did it not do anything at all?
Did you even attach the script to your player GameObject? Did said ‘player’ have a Rigidbody attached? How as the Rigidbody configured?
What tutorial did you follow? Do you understand we don’t know everything in your head?