- Home /
Ladder doesn't want to work! Please help!
I've got a ladder script, attached to an object with a trigger box collider, but it just doesn't work! Can anyone tell me what's wrong? Here's the script:
var Player : GameObject;
var CanClimb : boolean = false;
function Update () {
if(Input.GetKey(KeyCode.W)){ if(CanClimb == true){ Player.animation.enabled = true; Player.animation.Play("ClimbLadder"); } else Debug.Log("Player can't climb"); } if(!Input.GetKey(KeyCode.W)){ if(CanClimb == true){ Player.animation.enabled = false; } else Debug.Log("Player can't climb"); }
}
function OnTriggerEnter (other : Collider) {
if(other.gameObject.tag == "Player"){
CanClimb = true;
}
}
function OnTriggerExit (other : Collider) {
if(other.gameObject.tag == "Player"){
CanClimb = false;
}
}
What is happening when this code runs? What would you like to happen? What have you tried to resolve this issue?
Nothing happens! The player doesn't react at all, just passes through the collider! I'd like him to smoothly climb up the ladder
Answer by Muuskii · Aug 07, 2013 at 06:20 PM
You don't have any code that alters the way that the player is moving at all. I'm assuming you have some sort of character controller script? That's where you need to be checking for if the player is climbing and if so to raise slowly while ignoring any movement controls.
Your answer
Follow this Question
Related Questions
2D Platform game ladder climbing 1 Answer
Ladder script not working? 0 Answers
Need help scripting ladders for a 3d Top-Down level 2 Answers
Why won't my ladder script work? 0 Answers