28 Creating a Ladder in Unity

Поділитися
Вставка
  • Опубліковано 4 лют 2025

КОМЕНТАРІ • 12

  • @lazikbro12
    @lazikbro12 2 роки тому

    my character stays on ladder and cant exit it and press s doesnt work

  • @plekiko5180
    @plekiko5180 3 роки тому +3

    It Works Like a Charm! Here ya go the code.
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class LadderScript : MonoBehaviour
    {
    public Transform playerController;
    bool InsideLadder;
    public float LadderHeight = 3.3f;
    public PlayerMovement playerInput;
    void Start()
    {
    playerInput = GetComponent();
    InsideLadder = false;
    }
    private void OnTriggerEnter(Collider col)
    {
    if(col.gameObject.tag == "Ladder")
    {
    playerInput.enabled = false;
    InsideLadder = !InsideLadder;
    }
    }
    private void OnTriggerExit(Collider col)
    {
    if(col.gameObject.tag == "Ladder")
    {
    playerInput.enabled = true;
    InsideLadder = !InsideLadder;
    }
    }
    void Update()
    {
    if(InsideLadder && Input.GetKey("w"))
    {
    playerController.transform.position += Vector3.up/LadderHeight;
    }
    }
    }

  • @wafeeeel5563
    @wafeeeel5563 4 роки тому +1

    Thank you for this tutorial!

  • @funkyfun3463
    @funkyfun3463 2 роки тому

    I have a problem that the when the player touches the ladder it becomes infinite like neverending ladder. I know where the problem is but I dont know ho to fix it. In ontriggerenter it is turning off his collider and the there is nothing to check that the player is out

    • @jordancash80
      @jordancash80  2 роки тому

      Not sure why the collider would be disabled while in the ladder trigger. I don't believe any of the code disables the players collider. Maybe try checking the ladder height to be sure the player exits the trigger.

  • @SkyLeon-iu3ee
    @SkyLeon-iu3ee 3 роки тому

    exactly what i did in my script...Only,my character sort of jitters at the top of ladder.Not sure how to fix it.But if i don't let go W key,all is fine.How about jumping from ladder to ladder,or from wall to wall?Would be interesting for some kind of adventure/action platformer(2.5D side scroller)

  • @isabellamorris6222
    @isabellamorris6222 4 роки тому +2

    Hi, this is really good but my player is getting stuck going up the ladder for some reason. Didn't know if you ever experienced this issue with ladders before.

    • @sandeepanchoudhury-8j-164
      @sandeepanchoudhury-8j-164 3 роки тому

      make a platform and put it little bit above the ladder and place it behind then after getting up the ladder press w to climb up the platform. Hope this solves your problem. :)

    • @lazikbro12
      @lazikbro12 2 роки тому

      @@sandeepanchoudhury-8j-164 me. nope still

  • @henryrobersonn
    @henryrobersonn 4 роки тому +1

    wow this worked great, thanks!

  • @yoyu7685
    @yoyu7685 4 роки тому

    thank you so much