Climbing a ladder:

Haven’t been working with unity in a while and I just started a project. One of the first things I tried was to climb a ladder. I grabbed a ladder script and nothing works.

I have made a lot of changes trying this and that. But still nothing works.

Can I get some help?

var playerObject : GameObject;
var canClimb = false;
var speed : float = 1;
     
function Start () {
    
    playerObject = gameObject.Find("Worker");
}
     
function OnTriggerEnter (collider : Collision){
    
    if(collider.gameObject == playerObject){
        
        canClimb = true;
        
    }
}
     
    function OnTriggerExit (collider : Collision){
    
        if(collider.gameObject == playerObject){
            canClimb = false;
    
        }
    }
    
        function Update () {
    
            if(canClimb == true){
    
        
        
                if(Input.GetKey(KeyCode.Z)){
            
                    playerObject.transform.Translate (Vector3(0,1,0) * Time.deltaTime*speed);
    
                }
                if(Input.GetKey(KeyCode.S)){
            
                    playerObject.transform.Translate (Vector3(0,-1,0) * Time.deltaTime*speed);
        
        
        
                }
            }
        }

Are you using 2D or 3D physics? Collider is marked as [×] trigger? Your player has rigidbody?

If you put print(“enter”); and print(“exit”); inside those trigger functions, does it print? (so can see if the trigger fires or not)

also, docs say that type should be Collider, not Collision

function OnTriggerEnter (other : Collider) {

It’s 3D physics. No I am not using a rigidbody. I’ll test this.

Thanks.

I am getting this error now.

A lot of obsolete stuff going on…geeezzz…Do I need to relearn what little I know?