hello
I’m making an endless runner kinda thing there’s the problem:
the cube jumps just one time and then it doesn’t jump at all when it fall in the next tile / ground
Any help ??
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
public float speed = 15.0F;
private Rigidbody rb;
public Vector3 jump;
public float jumpForce = 2.0f;
public bool isGrounded;
//Use this for initialization
void Start () {
rb = GetComponent<Rigidbody>();
jump = new Vector3(0.0f, 2.0f, 0.0f);
}
// Update is called once per frame
void Update () {
transform.Translate (Vector3.forward * (speed) * Time.deltaTime);
if (Input.GetKeyDown(KeyCode.Space) && isGrounded)
{
rb.AddForce(jump * jumpForce, ForceMode.Impulse);
isGrounded = false;
}
}
}
I did as you said and I did a different one as well to test it still jumps in the first time and then nothing, the ground be true just in the first time and then turns false for ever :( >
– Bayan_x94void onCollisionEnter(Collision other) { if(other.gameObject.CompareTag("Ground")) { isGround = true; } }