Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Kolalamonkeys · May 25, 2021 at 11:02 PM · 2dplatformerclimbingwall jump

Wall jump doesn't change on x axis

I've been working on a movement script that allows my player to move, jump, climb walls, and wall jump. I've run into this problem where after the player has been climbing, the wall jump only moves the player on the y-axis, and they don't move out. Here is my wall script so far:

     void CheckSurroundings()
     {
         isGrounded = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, whatIsGround);
         isTouchingFront = Physics2D.OverlapCircle(frontCheck.position, wallCheckRadius, whatIsWall);
         isTouchingClimbableFront = Physics2D.OverlapCircle(frontCheck.position, wallCheckRadius, whatIsGround);
         notOnLedge = Physics2D.OverlapCircle(ledgeCheck.position, wallCheckRadius, whatIsGround);
     }
 
     void WallMechanincs()
     {
         if (isTouchingClimbableFront && Input.GetKey(KeyCode.X))
         {
             wallGrab = true;
         }
         if (!isTouchingClimbableFront || !Input.GetKey(KeyCode.X))
         {
             wallGrab = false;
         }
 
         if (!notOnLedge && wallGrab && Input.GetKey(KeyCode.UpArrow))
         {
             rb.position = ledgeCheck.position;
         }
 
         if (wallGrab)
         {
             if (!wallJumping)
             {
                 rb.gravityScale = 0;
                 if (Input.GetKey(KeyCode.UpArrow))
                 {
                     rb.velocity = new Vector2(rb.velocity.x, wallClimbSpeed);
                 }
                 else if (Input.GetKey(KeyCode.DownArrow))
                 {
                     rb.velocity = new Vector2(rb.velocity.x, -wallClimbSpeed);
                 }
                 else
                 {
                     rb.velocity = new Vector2(rb.velocity.x, 0);
                 }
             }
         }
         else
         {
             rb.gravityScale = originalGravity;
         }
 
 
         if (isTouchingFront && !isGrounded && moveInput != 0)
         {
             wallSliding = true;
         }
         else
         {
             wallSliding = false;
         }
 
         if (wallSliding)
         {
             rb.velocity = new Vector2(rb.velocity.x, Mathf.Clamp(rb.velocity.y, -wallSlidingSpeed, float.MaxValue));
         }
 
         if (Input.GetKeyDown(KeyCode.Space) && wallSliding || Input.GetKeyDown(KeyCode.Space) && wallGrab)
         {
             wallJumping = true;
             Invoke(nameof(SetWallJumpingToFalse), wallJumpTime);
         }
 
         if (wallJumping)
         {
             rb.velocity = new Vector2(xWallForce * -moveInput, yWallForce);
         }
     }
 
     void SetWallJumpingToFalse()
     {
         wallJumping = false;
     }
 }

Here's the full code: https://codeshare.io/Gb41Bj

Any help would be greatly appreciated! Thanks in advance!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Kolalamonkeys · May 26, 2021 at 04:07 AM

I found the answer. The wall jump was using -moveInput, but when there is no moveInput that means it will not move on the x. I need to change it to detect which wall the player is on and move the opposite direction.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

283 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

[2D] [C#] Player dying at respawn at checkpoint 1 Answer

How to determine if the player can jump, without using raycasts. (2D) 1 Answer

2D Platformer Reload Game On Collision With Sprite 1 Answer

2D or 3D settings for a 2.5D game? 2 Answers

How to make character stop at wall? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges