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.