I don’t recall seeing anywhere in the Terms of Service where we’re required to answer questions posed on these forums.
Is it unfair that people are skipping over your questions? Or is it your attitude that is encouraging it? Because with the statements you’ve made in that post, I don’t want to assist you in the slightest.
Frustration like this will result in no responses, but shhhhhure why not I’ll look over the question give me a second.
Buuut before that let me help you a little more for later questions, try asking questions in this format, it really helps if you’re not good at asking questions.
Problem : State the problem - I’ve determined you’re having issues figuring out how to add jumping to your game. What part are you having issues with, the input? or the actual jumping? Without that we can’t really tell you how to fix what you have and if we do, there will likely be 20 different responses with different ways and you will likely get confused.
What would you like to do with the code: Tell us what you’re trying to accomplish and whether there are any constraints on what can or cant be used to accomplish it.
Give the code: You got this one done alright.
Lastly unrelated, but are you doing this as part of a tutorial? or just learning? or for school?
BUT to answer, lets see… For a jump you’re on the right track you want an input.getkeydown(KeyCode.Space), which will basically tell the game frame that you’ve hit the space bar. As for jumping there are several ways to go about doing that,
Go to API Page, Look up Transform.Translate(); It takes a vector3, which controls 3 axes.
^For that Y Value if you just usea value and dont use any Mathf class functions to smooth the movement its going to look pretty bad, so I’d suggest looking into Mathf.Lerp and other functions that could be useful in smoothing that jump.
The second method is probably more practical. If you have a rigidbody attached to the player you can add a force to it,
Go to API page, Look up Rigidbody.AddForce(); It takes a vector3 value as a parameter which again control the axes.
And obviously, you’d want to check for grounded to ensure that your character is on the ground. To do a double jump just have a few if statements that toggles a seperate boolean values so that checks for,
if statement 1 - bool value - true if grounded, false if not grounded.
a. whether you’re grounded - Allows for you to jump.
if statement 2 - bool value - false if jumped once true if jumped twice.
b. Once you’ve jumped, whether you’ve jumped twice.
Then you just reset the bool value for double jump back to false when you’re re grounded.
School project? If thats the case, me telling you does you nothing, so you’re going to have to work for this one. I’ve given some starting points above.
Well in any case learning to use the API pages for learning is a valuable skill with any program, so hug your new friend the API page and have a sleepover, you can stay up as late as you want reading through it. For a new programmer I’d suggest learning all you can about TRANSFORMS, as well as VECTOR3’s, and QUATERNION’S. Additionally, things like RIGIDBODY can be useful in some scenarios, in fact most scenarios. All of these are classes that can be found here, with all of their functions listed.
Here is a link to Rigidbody, get reading, and feel your brain grow.