i want to make a character controller, but unity sayd that the script has an error here’s the script:
var walkSpeed: float = 7;
var crouchspeed: float = 3;
var runspeed: float = 15;
private var chMotor: CharacterMotor;
private var ch: CharacterController;
private var tr: Transform;
private var height: float;
function Start(){
chMotor = GetComponent(CharacterMotor);
tr = transform;
ch = GetComponent(CharacterController);
height = ch.height;
}
function Update(){
var h = height;
var speed = walkspeed;
if(ch.isGrounded && Input.GetKey("left shift") || Input.GetKey("right shift"));{
speed = runspeed
}
if(Input.GetKey("left control"));{
h = 0.5 * height;
speed = crouchspeed;
{
chMotor.movement.maxForwardSpeed = speed;
var lastHeight = ch.height;
ch.height = Mathf.Lerp(ch.height,h,5*Time.deltaTime);
tr.position.y +=(ch.height-lastHeight)/2;
}