- Home /
Ladder Problem
Hello, I created a script which checks whether you're inside the ladder collider and if you are and hold C it moves you up. The problem is that when I hold C it goes me up but then I fall down all the time...
What's the problem?
Here's the code:
var inside : boolean = false;
private var FPSInput : FPSInputController;
function Start() {
FPSInput = GetComponent(FPSInputController);
}
function OnTriggerEnter(col : Collider) {
if(col.gameObject.tag == "Ladder") {
inside = true;
}
}
function OnTriggerExit(col : Collider) {
if(col.gameObject.tag == "Ladder") {
inside = false;;
}
}
function Update() {
if(Input.GetKey(KeyCode.C) && inside) {
this.transform.position.y = this.transform.position.y + (5*Time.deltaTime);
FPSInput.enabled = false;
}
if(Input.GetKeyUp(KeyCode.C) && inside) {
FPSInput.enabled = true;
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613142630im_/https://answers.unity.com/themes/thub/images/avi.jpg)