Hey guys im new to unity and I've been using chatgpt to help me make my platformer game for my high school capstone. I've been trying to change the jump force in this player movement script but my player jumps the same height:
`using UnityEngine;
using UnityEngine.SceneManagement;
public class PlayerMovement : MonoBehaviour
{
public float moveSpeed = 5f;
public float jumpForce = 25f;
private Rigidbody2D rb;
private bool isGrounded;
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
void Update()
{
// Auto move right using correct Rigidbody2D property
rb.velocity = new Vector2(moveSpeed, rb.velocity.y);
// Jump
if (Input.GetKeyDown(KeyCode.Space) && isGrounded)
{
rb.linearVelocity = new Vector2(rb.linearVelocity.x, jumpForce);
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("Ground"))
isGrounded = true;
if (collision.gameObject.CompareTag("Spike"))
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
private void OnCollisionExit2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("Ground"))
isGrounded = false;
}
}`