- Home /
Is this the right way to do Double jumping? C#
I have tried to make a double jumping feature in my game, but it wont work. My game is on a spherical world and here is my code:
if (Input.GetButtonDown ("Jump") && grounded && jumpCount < 2){ { rigidbody.AddForce(transform.up * jumpForce); jumpCount = jumpCount + 1; } }
if (grounded = true) {
jumpCount = jumpCount - jumpCount;
}
grounded = false;
Ray ray = new Ray (transform.position, -transform.up);
RaycastHit hit;
if (Physics.Raycast (ray, out hit, 1 + 0.1f, groundedMask))
{
grounded = true;
}
}
Can someone fix my code, or inform me in what i am doing wrong so i can fix it, i am a beginner at Unity. Thanks :D
Answer by HappyLDE · Feb 19, 2015 at 05:33 PM
There is this tutorial by Mike Geig talking about double jumping: https://www.youtube.com/watch?v=Xnyb2f6Qqzg
Ok wow, thank you, this is what i wanted :D, Thanks so much.
Can i just say for anyone with the same problem, the tutorial talks about double jumping here:
http://youtu.be/Xnyb2f6Qqzg?t=1h12m58s
or at 1:13:00
Your answer
Follow this Question
Related Questions
restrict number of double jumps 1 Answer
Double Jump With UI BUTTONS; 0 Answers
Double jump with touch 1 Answer
Counter for double jump don't work 1 Answer
third person double jump 0 Answers