so i have this code and ive tryed co-routines but they dont work and it just bugs up, and ive tryed changing the speed by Time.deltaTime, but that doesnt work, any ideas on how to make my player slowly start to sprint?
var walkSpeed: float = 7; // regular speed
var runSpeed: float = 20; // run speed
private var chMotor: CharacterMotor;
private var ch: CharacterController;
private var tr: Transform;
private var height: float; // initial height
function Start(){
chMotor = GetComponent(CharacterMotor);
tr = transform;
ch = GetComponent(CharacterController);
}
function Update(){
var h = height;
var speed = walkSpeed;
if (ch.isGrounded && Input.GetKey("left shift") || Input.GetKey("right shift") && speed < runSpeed){
speed = runSpeed;
chMotor.movement.maxForwardSpeed = speed;
}
chMotor.movement.maxForwardSpeed = speed; // set max speed
}