Hi all,
When I press my left mouse button (Fire 1), the bird flies/flaps/jumps 1 instance higher up in the air. But when I keep my left mouse button pressed, it keeps flying continuously.
How can I remove this continuous option? The player just needs to able to press the left mouse button and flap when he clicks. He should not be able to keep the left mouse button pressed and flying continuously. Quite new to Unity, so far the experience has been great.
// Update is called once per frame
void Update()
{
// Keep the player within bounds.
if (transform.position.y > verticalLimit) {
transform.position = new Vector3(transform.position.x, verticalLimit, transform.position.z);
playerRigidbody.velocity = new Vector2(playerRigidbody.velocity.x, 0);
} else if (transform.position.y < -verticalLimit) {
Kill ();
}
// Make the player move vertically.
if (frozen == false && Input.GetAxis (“Fire1”) == 1f) {
Flap ();
}
}
void Flap () {
playerRigidbody.velocity = new Vector2 (playerRigidbody.velocity.x, jumpingSpeed);
flapSoundSource.Play ();
}