- Home /
I have a problem with my c# code to make my charaktercontroller jump.
Hi guys. I am new to programming and have a problem getting my character controller to jump. I tried a code from a youtuber but this only lets the controller jump 3 times
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class sprung : MonoBehaviour
 {
     private CharacterController controller;
     private float verticalVelocity;
     private float gravity = 14.0f;
     private float jumpForce = 10.0f;
  
 
     private void Start()
     {
         controller = GetComponent<CharacterController>();
 
   
     }
 
     private void Update()
     {
         if (controller.isGrounded)
         {
             verticalVelocity = -gravity * Time.deltaTime;
             if (Input.GetKeyDown(KeyCode.Space)) 
             {
                 verticalVelocity = jumpForce;  
             }
         }
         else
         {
             verticalVelocity -= gravity * Time.deltaTime;
 
         }
 
         Vector3 moveVector = new Vector3(0, verticalVelocity, 0);
         controller.Move(moveVector * Time.deltaTime);
 
     }
 }
 
 
Answer by kayastassya · Jun 28, 2020 at 11:16 AM
another small appendix: can anyone send me a code that only make the charakter jump and nothing else?
thanks a lot
~kaya schubert
Hey @kayastassya, Check it out here: https://answers.unity.com/questions/1207400/how-to-make-a-simple-jump-script-in-3d-c.html
Cheers
thx @RodrigoAbreu but im working with a charakter controller and not with a rigitbody qwq
Your answer
 
 
             Follow this Question
Related Questions
How would I get my character to be able to move while in the air after a jump? 1 Answer
How to move while jumping? 1 Answer
how to get the default third person character controller in unity 5 to move in midair 0 Answers
I can't do that my character jumps while running 0 Answers
Character Controller Jitters When Jumping Next To Objects 4 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                