Hi,
Sorry for the noob questions but I have a bird in a third person view. And when I press and hold W I want the bird to fly up continuously until I release W at which point the bird should glide down (bird has gravity).
I am having a bit of a hard time making the bird go up continuously. Everything else works fine.
I have tried using transform.Translate, rigidbody.AddForce, and CharacterController but my solutions are not working as I want them to.
With how it is right now, when I press and hold W the bird moves up but stops going up after a certain point and begins to fall down even if I am still holding the W key. And when it is falling, if I press W it does not go up again, it will fall to the ground, and only when it is on the ground I can make it go up again. Which seems quite strange to me…
Anyone have any suggesions?
if (Input.GetKey(KeyCode.W))
{
anim.SetBool("isFlying", true);
transform.Translate(Vector3.up * Time.deltaTime, Space.World);
}
if (Input.GetKey(KeyCode.W))
{
anim.SetBool("isFlying", true);
transform.Translate(new Vector3(0, speed * Time.deltaTime, 0));
}
if (Input.GetKey(KeyCode.W))
{
anim.SetBool("isFlying", true);
rigidBody.AddForce(new Vector3(0f, flyUpForce, 0));
}