Hi,i have made crouch script,but i cant figure out : How can i make my player walks slower when im crouched,how to do that? Can anyone please help me? Can someone modify this script that it works like i want? ![]()
P.S. Im using character controller,i dont have character motor…
Here is my script:
var controller : CharacterController; //ADD in Inspector
var isCrouched : boolean = false;
var checkCeiling : boolean;
function Update () {
if(Input.GetKey("c")){
if(!isCrouched) crouch();
}else{
if(isCrouched !checkCeiling) stand();
}
if(isCrouched){
if(Physics.Raycast (transform.position, Vector3.up, 2.0)){
checkCeiling = true;
}else{
checkCeiling = false;
}
}
}
function crouch(){
controller.height /= 2;
isCrouched = true;
}
function stand(){
gameObject.transform.position.y += controller.height/2;
controller.height *= 2;
isCrouched = false;
}