28 Creating a Ladder in Unity

Поделиться
HTML-код
  • Опубликовано: 18 ноя 2024

Комментарии • 12

  • @lazikbro12
    @lazikbro12 Год назад

    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;
    }
    }
    }

  • @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)

  • @wafeeeel5563
    @wafeeeel5563 4 года назад +1

    Thank you for this tutorial!

  • @isabellamorris6222
    @isabellamorris6222 3 года назад +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 Год назад

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

  • @yoyu7685
    @yoyu7685 4 года назад

    thank you so much

  • @henryrobersonn
    @henryrobersonn 4 года назад +1

    wow this worked great, thanks!