Well, I was trying to create a script which would allow my character to increase speed when a key is pressed, but in the script, it gives me this error saying that other is an unknown identifier. Any help on this? Oh, and it is written in Javascript…
var runSpeed: float = 10.4;
var runG: float = 3.6;
var regularSpeed: float = 5.2;
var regularG: float = 7.2;
private var isrunning : boolean = false;
function Update () {
if (Input.GetKey("Run")) {
Running ();
}
else (Otherwise ());
}
function Running () {
var chMotor: CharacterMotor = other.GetComponent(CharacterMotor);
if (chMotor){ // make sure CharacterMotor exists
chMotor.movement.maxForwardSpeed = runSpeed;
chMotor.movement.maxSidewaysSpeed = runSpeed;
chMotor.movement.maxBackwardsSpeed = runSpeed;
chMotor.movement.gravity = runG;
}
}
function Otherwise () {
var chMotor: CharacterMotor = other.GetComponent(CharacterMotor);
if (chMotor){
chMotor.movement.maxForwardSpeed = regularSpeed;
chMotor.movement.maxSidewaysSpeed = regularSpeed;
chMotor.movement.maxBackwardsSpeed = regularSpeed;
chMotor.movement.gravity = regularG;
}
}