Quantcast
Channel: Questions in topic: "ios"
Viewing all articles
Browse latest Browse all 4709

If Grounded

$
0
0
Hello everybody! I want to make a jumping function, and I can jump, but I am writing an if grounded variable. My code so far is: using UnityEngine; using System.Collections; public class jumpAfterTest : MonoBehaviour { public bool isGrounded = true; //specifies if touching gameobject floor_big // in this case, it specifies is touching ground //therefore, mole can jump public float jumpheight = 3500; void update() { isGrounded = false; } public void JAT () { Debug.Log("Me is JAT"); //add effect here (old note) if (isGrounded == true){ GetComponent().AddForce (transform.up * jumpheight); } //need if grounded variable (old note)(not working) } void OnCollisionEnter (Collision col1) { if (col1.gameObject.name == "floor_big") { isGrounded = true; //Destroy(col1.gameObject); } } } I can jump, but I can also double jump. And triple jump, quadruple jump, quintuple jump, etc. Basically I can fly. I want to limit to one jump, like in real life. I don't know why my script isn't working. Please help out. Thanks! By the way, I am relatively new.

Viewing all articles
Browse latest Browse all 4709

Trending Articles