# Why is my character jumping at different heights randomly?

I have a character controller on my character's gameobject and I'm trying to make the character jump. This is working but sometimes he jumps way higher than other times. Does anyone know why this is happening? Here's the code:

    using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Movement : MonoBehaviour
{
CharacterController cc;
public float Speed;
float Forward;
float Sideways;
float vertical;
public float gravity;
public float Jump;

// Start is called before the first frame update
void Start()
{
cc = GetComponent<CharacterController>();
}

// Update is called once per frame
void Update()
{
Forward = Input.GetAxis("Vertical") * Speed;
Sideways = Input.GetAxis("Horizontal") * Speed;

if (!cc.isGrounded)
{
vertical -= gravity * Time.deltaTime;
}
else
{
if (Input.GetKeyDown(KeyCode.Space))
{
vertical = Jump * Time.deltaTime;
}

vertical = -8 * Time.deltaTime;
}

Vector3 Delta = transform.TransformDirection(Sideways, vertical, Forward);

cc.Move(Delta * Time.deltaTime);
}
}

• You've scaled the launch velocity by the duration of the current frame — was this deliberate? – DMGregory May 14 at 1:13
• Yes, my character was teleporting otherwise. I've changed the code however and it's working now. Should I post it as the answer? – JeffBrin May 14 at 1:38
• Yes, working solutions should be posted as answers. – DMGregory May 14 at 1:39