How can you make a jump to a point using the Character Controller?

Game Development Asked by Aimon Z. on December 25, 2020

I found an example with which the CharacterController can jump, but it does not work to remake it so that it jumps to a certain point/distance, and the jumpHeight itself was calculated for speed and gravity, I found this article on Wikipedia, but I don’t even know why to begin.

public class ExampleClass : MonoBehaviour
    public float speed = 6f;
    public float jumpHeight = 8f;
    public float gravity = 20f;

    private Vector3 moveDirection =;

    CharacterController controller;

    void Start()
        controller = GetComponent<CharacterController>();

    void Update()

        if (controller.isGrounded)
            moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
            moveDirection = transform.TransformDirection(moveDirection);
            moveDirection *= speed;
            if (Input.GetButton("Jump"))
                moveDirection.y = jumpSpeed;

        moveDirection.y -= gravity * Time.deltaTime;
        controller.Move(moveDirection * Time.deltaTime);

    // Method for jump, calling from other script.
    void Jump(float pointX)

I can’t find examples for the Character Controller, although I did find one for the Rigidbody.

Add your own answers!

Related Questions

Convert a string to a gameobject name

1  Asked on December 1, 2021 by stormzy18


Jumping up quicker? (Paper Mario style jump)

1  Asked on December 1, 2021 by spottel


A* Pathfinding Finding One of Many Goals

1  Asked on November 29, 2021 by user6256


Wheel rotation for a raycast car in Unity?

1  Asked on November 29, 2021 by john-545


Unity “scrape away” effect

0  Asked on November 24, 2021 by darren-swords


Initial setting of camera and ppu to match playing table

1  Asked on November 21, 2021 by zibelas


LibGDX – Tilemap Wall Collision Detection Issues

2  Asked on November 20, 2021 by james-stoddern


Tilemaps not showing up on Android build

1  Asked on November 18, 2021 by jcorretjer


Unity: Sprite stretch issue

1  Asked on November 14, 2021 by tikeb


Unity UI, how to hide on play

2  Asked on November 12, 2021


Alternative path not working

1  Asked on November 12, 2021 by dsngl-tibor


Unity – Understanding the SRP batcher

2  Asked on November 12, 2021 by majs


Ask a Question

Get help from others!

© 2023 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP