Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Trying to code wall jump.

Discussion in 'Getting Started' started by TheKrazyDev, Mar 2, 2022.

  1. TheKrazyDev

    TheKrazyDev

    Joined:
    Sep 8, 2021
    Posts:
    107
    Hello. I'm trying to code 3d wall jump and was wondering the basic idea. I'm not looking for a script just wanna know what you'd wanna do. Like set up box colliders? Make a box cast on the sides of you? Raycast? Stuff like that.
     
  2. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    950
    I would setup a wall layer and do a raycast with a layermask that only includes that layer. I would also check the normal:
    https://docs.unity3d.com/ScriptReference/RaycastHit-normal.html
    to see if the surface is indeed at the correct angle for a wall jump.

    The advantage of a raycast over a collision is that it allows the player to jump even if it's slightly away from the wall. You can tweak this distance separately from the actual collider.
     
  3. TheKrazyDev

    TheKrazyDev

    Joined:
    Sep 8, 2021
    Posts:
    107
    Ah OK thanks.