var walkingSpeedStart : float = 5;
var walkingSpeedFinal : float = 10;
var accelerationSpeed : float = 2;
var overallSpeed;
var jumpSpeed : float = 5;
var gravity : float = 5;
var slideSpeed : float = 2;
private var moveDirection : Vector3 = Vector3.zero;
var hitWallLeft : boolean = false;
var hitWallRight : boolean = false;
var hitwallLeftCount = 0;
var hitwallRightCount = 0;
var dragDownWall : boolean = true;
function Update(){
var controller: CharacterController = GetComponent(CharacterController);
overallSpeed = Mathf.Lerp(walkingSpeedStart,walkingSpeedFinal,accelerationSpeed);
moveDirection = new Vector3(0, 0, Input.GetAxis("Horizontal"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= overallSpeed;
if(controller.isGrounded){
hitwallLeftCount = 0;
hitwallRightCount = 0;
if(Input.GetKeyDown(KeyCode.Space)){
moveDirection.y = jumpSpeed;
}
}
if(!controller.isGrounded hitWallLeft == true hitwallLeftCount < 1){
moveDirection.y = jumpSpeed;
hitwallLeftCount += 1;
hitwallRightCount -= 1;
}
if(hitwallLeftCount >= 1){
hitwallLeft = false;
}
if(!controller.isGrounded hitWallRight == true hitwallRightCount < 1){
moveDirection.y = jumpSpeed;
hitwallRightCount += 1;
hitwallLeftCount -= 1;
}
if(hitwallRightCount >= 1){
hitwallRight = false;
}
if(dragDownWall == true !controller.isGrounded){
moveDirection.y -= slideSpeed * Time.deltaTime;
}
if(dragDownWall == true controller.isGrounded){
}
controller.Move(moveDirection * Time.deltaTime);
moveDirection.y -= gravity * Time.deltaTime;
}
The player falls so slowly and not sure why