Hi!
I have in my game some ladders and want to try the FPS the rise.
In the ladders i have a cube as a trigger and i have this basic script too:
public float velocidadSubida = 5f;
bool DentroEscalerilla = false;
void OnTriggerEnter(Collider hit){
//Si es el personaje el que esta en la escalerilla
if (hit.gameObject.tag == "Escalerilla") {
DentroEscalerilla = true;
}
}
void OnTriggerExit(Collider hit){
if (hit.gameObject.tag == "Escalerilla") {
DentroEscalerilla = false;
}
}
void Update(){
Vector3 movimiento = new Vector3 (0, velocidadSubida*Time.deltaTime, 0);
if (DentroEscalerilla == true){
if (Input.GetKey(KeyCode.W))
{
gameObject.transform.position += movimiento;
}
}
}
My First Person Controller start to climb but then stop and fall to the ground again. If i hold down “W” the character continuously start to up and fall.
What is my error? I’ve also tried with the “OnTriggerStay”.
Thankss!!