speed problem

heey people,
I openend an old project and played the level. I found that i moved slowly so I adjusted the speed but then he wouldn’t jump right anymore. So I adjusted the Jumpspeed, didn’t helped. then I played around with the gravity but I can’t find the jumpheight it had by: Speed= 6.2, JumpSpeed = 7, Gravity = 25.

/// This script moves the character controller forward 
/// and sideways based on the arrow keys.
/// It also jumps when pressing space.
/// Make sure to attach a character controller to the same game object.
/// It is recommended that you make only one call to Move or SimpleMove per frame.    
var speed = 6.0;
var jumpSpeed = 8.0;
var gravity = 20.0;

private var moveDirection = Vector3.zero;

var hi = false;
//function OnControllerColliderHit(hit : ControllerColliderHit)
function OnTriggerEnter(hit : Collider)
{
if(hit.gameObject.tag == "bullit")
{
stats.health -= 15;

}
if(hit.gameObject.tag == "Spikes")
{
stats.health -= 30;
}
if(hit.gameObject.tag == "Potion")
{
stats.health = stats.max_health;
}

}
function FixedUpdate() {
    var controller : CharacterController = GetComponent(CharacterController);
    if (controller.isGrounded) {
        moveDirection = Vector3(Input.GetAxis("Horizontal"), 0,
                                speed-5);
        moveDirection = transform.TransformDirection(moveDirection);
        moveDirection *= speed;
        
        if (Input.GetButton ("Jump")) {
            moveDirection.y = jumpSpeed;                
         }
    }

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

I don’t know if anyone can helped me. but if you have suggestions, they are welcome. :slight_smile:

Hi,
The problem is that when i press a key it goes at once very fast(Look at the vid and it happens just once at the begin):

// This script moves the character controller forward 
/// and sideways based on the arrow keys.
/// It also jumps when pressing space.
/// Make sure to attach a character controller to the same game object.
/// It is recommended that you make only one call to Move or SimpleMove per frame.    
var speed = 13;
var jumpSpeed = 8.0;
var gravity = 20.0;

private var moveDirection = Vector3.zero;

var hi = false;
//function OnControllerColliderHit(hit : ControllerColliderHit)
function OnTriggerEnter(hit : Collider)
{
if(hit.gameObject.tag == "bullit")
{
stats.health -= 15;

}
if(hit.gameObject.tag == "Spikes")
{
stats.health -= 30;
}
if(hit.gameObject.tag == "Potion")
{
stats.health = stats.max_health;
}

}
function FixedUpdate() {
    var controller : CharacterController = GetComponent(CharacterController);
    if (controller.isGrounded) {
        moveDirection = Vector3(Input.GetAxis("Horizontal"), 0,
                                speed-5);
        moveDirection = transform.TransformDirection(moveDirection);
        moveDirection *= speed;
        
       /* if (Input.GetButton ("Jump")) {
            moveDirection.y = jumpSpeed;                
         }*/
    }

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

What could be the problem?

Time.deltaTime probably spikes on your first update. Print it and see if that is the case.

ok i printed it out and got on the time that it goes fast around 0.008 and normal around 0.004