ladder

hello people,

im making a vr project in unity with some ladders.
how do i make a working ladder, when i walk against the ladder i move up when i press down i move down?

does anybody have expirience with this?

sorry, not good at scripting.

give the ladder a trigger collider, so you know if the player has walked into one. On collision set a variable in the player controller that you’re in ladder “mode” and alter the control scheme accordingly.

thanks for your reply. im not so good in scripting, but i think i know what you mean.

something like: if get component fps controller triggers box collider move on vertex…?

i tried the scripting but i cant do it…

i will put a picture of my setup in this post.
hope someone can help me with a script for going up and down on a ladder.
using keys W and S.

i have:
-player with rigidbody
-wall
-ladder
-trigger (box collider)

screen shot of the setup:

using UnityEngine;
using System.Collections;

public class ladder : MonoBehaviour{
    void OnTriggerEnter(Collider other)
    {
        Debug.Log("entered trigger, player should move upwards 
but you are too bad at scripting to solve this yourself so you have to aks it on a forum");
    }
}

i tried this as a test script.
(as you can see. not good at scripting XD)

im getting the message in the console, but now i want the player to move up when i walk forward

how are you moving the player?

i have the standard character controller. controlling it with WASD and mouse.

would like to move the player up and down the ladder with the keys W and S

i founda javascript and tried converting it to c#

this is what i got +8 errors

would appriciate it if someone could fix this thing for me :slight_smile:

using UnityEngine;
using System.Collections;

public class NewBehaviourScript : MonoBehaviour {

    public Transform Charactercontroller;
    public bool inside = false;
    public float heightfactor = 3.2f;

    private FPSInput FPSInputController;

    // Use this for initialization
    void Start () {
        FPSInputController = GetComponent(FPSInputController);

   
    }
    void OnTriggerEnter(Collider.col)
    {
        if(Collider.GameObject.tag == "ladder")
        {
            FPSInputController.enabled = false;
            inside = !inside;
        }
    }

    void OnTriggerExit(Collider.col)
    {
        if (Collider.GameObject.tag == "ladder")
        {
            FPSInputController.enabled = true;
            inside = !inside;
        }
    }

    // Update is called once per frame
    void Update () {
        if(inside == true && Input.GetKey("W"))
        {
            CharacterController.transform.position += Vector3.up / heightfactor;
        }
   
    }
}

then you need to understand how that code works, you’re going to need to make changes to it to make it work differently from the “standard”.

if you ever find yourself saying “I got an error” on these forums and you’re not pasting in the error to the post… well you’re doing it wrong :stuck_out_tongue: :slight_smile:
From a quick skim, lookup the correct c# GetComponent syntax, and correct the typos. Scripting is case sensitive.

ok i understand. do you know some tutorials and how to videos on basic scripting