I don’t know why the script posted all janky but here it is in all its “glory”
My problem is I’m trying to make 3 jumps but I can only make 1. The Jumps float is reset to the value of the JumpLevel float every time the player collides with the tags Ground or JumpPad, and every time a Jump is made if Jumps > 0 -----> Jumps -= 1
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WeedWhackerMan : MonoBehaviour
{
public float JumpPower = 1f;
public float JumpLevel = 2f;
public float Jumps = 3f;
public float JumpsLeft = 1f;
public bool isJump = false;
public float JumpPadForce = 109f;
public Rigidbody WWM;
public float MoveSpeed = 5f;
// Start is called before the first frame update
void Start()
{
Jumps = JumpLevel;
WWM = GetComponent<Rigidbody>();
}
void Update()
{
if (Input.GetButtonDown("Jump") && Jumps > 0)
{
Jump();
}
}
public void Jump()
{
WWM.AddForce(new Vector3(0, JumpPower, 0), ForceMode.Impulse);
Jumps -= 1;
isJump = true;
}
public void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.tag == "Ground")
{
Jumps = JumpLevel;
isJump = false;
}
if (collision.gameObject.tag == "JumpPad")
{
Jumps = JumpLevel;
JumpPad();
isJump = false;
}
}
public void JumpPad()
{
WWM.AddForce(new Vector3(0, JumpPadForce, 0), ForceMode.Impulse);
}
}
Sorry if this question isn’t written well. I’ve been working on this for hours now and my brain hurts lol