Quantcast
Channel: Questions in topic: "hold"
Viewing all articles
Browse latest Browse all 154

how can my player keep jumping wen it hit ground again?

$
0
0
I want to make my player to keep jumping wen it hit the ground a gain if I'm holding my button down, but right know it only jumps one for each time a click or hold the button . is for mobile divice. this is my script public enum type {LeftButton, RightButton, JumpButton,PouseButton}; public type buttonType; public float jumpHeight = 0.0f, moveSpeed = 0.0f; public GameObject playerObject = null; public GUITexture buttonTexture = null; private float myTouchDT = 0; private Touch touch; private bool isGrounded; void OnCollisionEnter2D(Collision2D col) { if (col.gameObject.name == "ground") isGrounded = true; } void OnCollisionExit2D(Collision2D col) { if (col.gameObject.name == "ground") isGrounded = false; } void OnFirstTouchBegan(){ switch (buttonType) { case type.JumpButton: if (playerObject.GetComponent ().onGround) { if (myTouchDT < .7f) { playerRigidbody.AddForce (Vector2.up * jumpHeight, ForceMode2D.Impulse); // this make the object jump // esto checa si esta en el suelo o no pa ver si brinca o no Debug.Log ("small"); } else if (myTouchDT >= .7f) { playerRigidbody.AddForce (Vector2.up * jumpHeight, ForceMode2D.Impulse); // this make the object jump // esto checa si esta en el suelo o no pa ver si brinca o no Debug.Log ("keep jumping"); } myTouchDT = 0f; } break; } }

Viewing all articles
Browse latest Browse all 154

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>