Character won't stop Jumping
Hello, I'm trying to make a character jump by swiping up but I've run into an issue where it will continue to jump and fight gravity (i.e trying to keep jumping in the air, even while being dragged down.) I would like it to jump just once per swipe up. This is the current swipe code: if (TouchDetect.leftSwipe == LSwipe.LUp) { transform.Translate(Vector3.up*jumpheight*Time.deltaTime); } and here is where the enum of LUp is detected: if (currentSwipe.y > 0f && currentSwipe.x > -0.5f && currentSwipe.x < 0.5) { if (Total > compare + buffer) { SwipeText1.Ltouchtype = "LHCU"; leftSwipe = LSwipe.LHCU;
}
else{
SwipeText1.Ltouchtype = "LSU";
leftSwipe = LSwipe.LUp;
}
I'm under the assumption it has something to do with things not clearing the enum and it constantly detects LUp, but I'm not sure how to clear that with out using another swipe, which would interfere with controls. Any help would be greatly appreciated.
Answer by Rostam24 · Sep 17, 2015 at 07:37 AM
Is there a specific reason you are using transform.Translate for jumping? You might be better off using rigidbody AddForce instead. In this case, the action of swiping should call a method that adds force as an impulse to the rigidbody - and then you are all done!