Hello,
Please i have a problem, that i cant solve since a few days.
I want to make that a ball jump two time. First when we touch the screen. If the ball is grounded, it can jump and the second time when it is in the air. and with the same height.
This is my code, what i tried
void update {
if (Physics.Raycast(transform.position, -Vector3.up, raycastDistance))
{
isGrounded = true;
airCount = maxAirCount;
}
else
{
isGrounded = false;
}
if (isGrounded)
{
rb.velocity = Vector3.right * 190f * Time.deltaTime;
}
//Für Touch
if (Input.touches.Length > 0)
{
for (int i = 0; i < Input.touchCount; i++)
{
if ((Input.GetTouch(0).phase == TouchPhase.Began))
if (isGrounded)
{
rb.velocity = new Vector3(200f * Time.deltaTime, rb.velocity.y + normalJumpForce * Time.deltaTime, 0);
}
else if (airCount > 0)
{
airCount -= 1;
rb.velocity = new Vector3(200f * Time.deltaTime, rb.velocity.y + normalJumpForce * Time.deltaTime, 0);
}
}
}
}
The ball moves to the right. The height varies always.
Please i need your help !!