Move character with Character Controller and Rigidbody

I’m trying to get a character to move on the world like any game would. However I wish for the character to only jump once (no infinite jump). I have never used Character Controller before, but once I figured it out, I tested it and the character flies across the screen like crazy.
Assume it has been initialized correctly, the problem is between lines 25-30.

void Update(){
      
        if(con.isGrounded){
        //if (canJump) {
            if (Input.GetButtonDown ("Jump")) {
                GetComponent<Rigidbody> ().velocity = Vector3.up * JumpSpeed;
            }
        }

    }

    void FixedUpdate(){
          
        float horz = Input.GetAxis ("Horizontal");
        float vert = Input.GetAxis ("Vertical");

        //jump
        if (rb.velocity.y < 0) {
            rb.velocity += Vector3.up * Physics.gravity.y * (fallSpeed - 1) * Time.fixedDeltaTime;
        }
        else if (rb.velocity.y > 0 && !Input.GetButton ("Jump")){
            rb.velocity += Vector3.up * Physics.gravity.y * (quickJump - 1) * Time.fixedDeltaTime;
        }
          
        move = new Vector3 (horz, 0, vert); //I replace the float y value from 0 to physics.gravity.y to help variant 2, which makes the character fall faster, but the character ends up falling through the floor of the world still

        transform.Translate (move * speed * Time.fixedDeltaTime); //variant 1, works perfectly without Character Controller, but I need Character Controller. Moves super fast with Character Controller. Bounces off walls for some reason.

        con.Move(move * speed * Time.fixedDeltaTime);// variant 2, Moves too fast, doesn't fall fast, and falls through world floor. Movement is jittery as well


    }

I want it to work how variant 1 has it, but I need the Character Controller in there as well.

NOTE: variant 1 and 2 are never running at the same time.

You don’t want to use both the character collider and a rigidbody. You have to choose one or the other. See which you prefer.

If you haven’t already viewed some code like this: Unity - Scripting API: CharacterController.Move

thanks! I’ll check it out

Cool :slight_smile:

I’m sure there are many, many posts about char. controllers and rb character controllers, all over the forums. :slight_smile:

Simple movement & jump scripts, especially. Enjoy :slight_smile: