I couldn't make my character jump

I writed a code that i hoped would make my character move, but it didn’t work. Can you guys have a look at it?
using UnityEngine;

public class CharacterJump : MonoBehaviour
{
public float jumpForce = 5f; // The force applied to make the character jump
private Rigidbody rb;

void Start()
{
    // Get the Rigidbody component attached to the character
    rb = GetComponent<Rigidbody>();
}

void Update()
{
    // Jump when the Space key is pressed
    if (Input.GetKeyDown(KeyCode.Space))
    {
        rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
    }
}

}

After this code, nothing really happened and i don’t know how to add tags because i think i need to make a tag to make it work.

check this free asset code and how it deals with jump see if maybe you have missed a step or some option

1 Like

I think it would be better to use rb.velocity instead of rb.addforce. rb.addforce is generally used in the movement of objects such as bullets.

1 Like

thank you all :+1:

Hey, just a heads up, you’re marking your threads as Unity-services / Cloud-code, but they’re not. I’ll remove the tags for you this time.

Sorry, i am new to Unity Discussions and i don’t really know the tags really!