Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Wall jump and wall slide help!

Discussion in '2D' started by mrbadass_, Jan 2, 2020.

  1. mrbadass_

    mrbadass_

    Joined:
    Dec 17, 2019
    Posts:
    2
    So it's my first time making a game in unity and I need help with wall sliding. The wall sliding actually works but has errors. When I try sliding from a tall wall for more than 3 seconds the character suddenly stops and is stuck on the wall, the rigidbody y velocity is suddenly set to 0 which sets the bool isWallSliding to false which completely breaks the whole wall sliding script. It's my first time doing C# and making a game so cut me some slack I know my code is messy but please just help me out here.

    The logic of the code:
    If the player is not grounded and the linecast is hitting a wall and his input is either left or right and his rigidbody.velocity.y is less than 0 (meaning he is falling) set the bool isWallSliding to true. When isWallSliding is true apply a velocity of float wallSlideSpeed to his Y.

    I logged the values to the console and everything seemed fine until all of a sudden the velocity.y is set to 0 which turns the isWallSliding boolean to false which breaks the script since the players velocity.y has to be less than 0 which indicates he is falling.


    Update: The sliding works fine the problem was that my test level had like 20 colliders on one wall and it messed something up. Making the wall have one collider fixed it.
     
    Last edited: Jan 2, 2020
  2. mrbadass_

    mrbadass_

    Joined:
    Dec 17, 2019
    Posts:
    2
    Update: The sliding works fine the problem was that my test level had like 20 colliders on one wall and it messed something up. Making the wall have one collider fixed it.