how to jump?

i want to have code that when i use key space and control can jump?
please give me the code simple?

NEVER ask for code here. You have to learn yourself.

4 Answers

4

NO!

The site you happens to be on is UnityAnswers not UnityFreeCodeSamples. We are more then willing to help you. You are the only one hindering yourself. If you want good answers you will have to put some effort into it.

However when that said. I don’t know much about touch inputs and what you specifically are looking for. You will have to look for that on your own. But there are many different ways of ‘jumping’. That usually depends on how you character is build. If it is a rigidbody you can use rigidbody.AddForce to propel your character upwards. Here you must come up with your own way of detecting if the player is on the ground or not. Raycast and OnCollision type functions is generally a good idea.

If your player has a CharacterController you can use moveDirection here is an example. For measuring if you character is on the ground use isGrounded

In addition to your post. I must say that you are responsible for your own learning. We will go very far to help you, but if you are not responsible enough to care about learning the stuff we give you, it is simply just a waste of time. Am I right?

It is like school you look at your site mates results all the time, but suddenly you are leaving the school, but you must pass the final in order to go to a new place and educate yourself even further. But you know nothing by now because you looked at your frinds results all the time and you would most likely fail the final or get a bad grade because you did not take any responsibility yourself.

Here in Denmark we use AFAL Ansvarlig For Egen Læring. Which means that you alone are responsible for learning what you need to learn.

This is by no means just to pick on you. It is more of a eye opener I guess. Please take the time to learn the material we give you and study it carefully maybe you do not understand it and that is totally fine. You can just ask the guy using comments and he or her will be more than willing to clarify it.

Thank you.

AFAL? Don't you mean AFEL? ;) I am danish too. :)

Danish? ain't that some'in ya' eat? :o)

Wat u talk aboot? ^^

Nah that is Danish pastry.

In “Hitchhiker’s guide to the galaxy”, the hero wants to learn how to fly. This seems similar to your problem. The guide tells him that all you need to do is to throw yourself at the ground and then forgetting about it while you do it. Once you succeed, you float.

I think you should be able to use this approach for jumping too. Just move along and make light steps on the ground. Once you start to feel lighter, you push more force into the ground and suddently you start to jump.

I love this post

The secret to flying is to aim to hit the ground, and miss. (Secret- it's how spaceships work!)

I don’t know if you wanted something like this but anyway …You have a prefab with a fps.