Hello, I saw this script some where about 1/2 weeks back can’t remember where tho, I’ve edit it abit. The problem i’m having atm with the code is when i jump it doesn’t understand its touch the “Ground” again there like a little delay or lots of spamming to fix it. (The tag i’m using for the ground tag is “grounded” if you can help me it will be great help Script i am using can be found below.
Thank you very much
Luke
using UnityEngine;
using System.Collections;
public class Jump : MonoBehaviour {
public bool grounded = true;
public float jumpPower = 1;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(!grounded && GetComponent<Rigidbody>().velocity.y == 0) {
grounded = true;
}
if (Input.GetButtonDown("Jump") && grounded == true) {
GetComponent<Rigidbody>().AddForce(transform.up*jumpPower);
grounded = false;
}
}
}