This is what I have so far. Now I want to make him jump, but if I do it the same way I did the movement, how do I make him fall back to the ground? I saw someone talking about raycasting or something, can someone explain me how I could achieve to make him jump? Thanks for your time!
You really should just start learning unity3D before jumping into something. Maybe learn a few thing first. I can recomend Walkerboys Tutorial the is a good Maria turorial there. But you check for button "jump" is press then move the character in the y direction. (If you viewing from side) like a 2D scrolling game. Code (csharp): var JumpSpeed : int = 10; if (Input.GetKeyDown("jump")) { transform.translate(0,JumpSpeed,0); } Also check out move and simpelmove.
I know Unity pretty well, but I'm just completely horrible at coding, and I dont understand all of the examples in the scripting reference I tried doing exactly what you described, but that wont work because my character wont fall down to the ground again. He just keeps going up X amount of units and stays there.
Then the code works ^^ you can keep jumping because the is no check for grounding. If you have a Character controller on your mesh you can check for grounding. So as long as player not grounded he shouldent be able to push jump. And if not grounded move down. so would be something like. Code (csharp): var JumpSpeed : int = 10; var gravity : int : 10; var controller = GetComponent(CharacterController); if (controller.isGrounded) { if (Input.GetKeyDown("jump")) { transform.translate.y += jumpSpeed; } } // Apply gravity transform.translate.y -= gravity * Time.deltaTime; But this will also have it move tru the ground as the is no stopping translate. So the is another way, using move and simpelmove. And check move. Here the is also a script about all this . That why i said so in last post. But that script work perfectly if you are in a 3D world. So if it 2D just remove vertical check.
Character Controller is a way slower then using a Rigidbody and you can use Raycasts to check for grounding. Here is a Tutorial : http://unity3dtutorial.com/unity-3d...-jump-unity-3-rigidbody-character-controller/ Yannic