Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 vlakitus · Oct 22, 2018 at 01:33 PM · unity 2daddforceplatformerwall jump

Problem with Wall Jump - 2D

Hey Guy! I'm stuck

When the player performs a wall jump he sort of teleports to the side first and then moves straight up before falling back down.

Here is the method wallJump();

     void wallJump(){
  
  
         if (horizontalNumber > 0 && !faceLeft)
         {
             flipCharacter();
  
            // playerRb.velocity = (new Vector2(-horizontalNumber * wallJumpClimb.x * 50f, wallJumpClimb.y));
            // playerRb.velocity = Vector2.left * jumpForceCharacter * -wallJumpClimb.x;
             playerRb.AddForce(new Vector2(-horizontalNumber * wallJumpClimb.x * 5f, wallJumpClimb.y));
  
             print("Pulei da direita");
         }
         else if (horizontalNumber < 0 && faceLeft)
         {
             flipCharacter();
             playerRb.velocity = (new Vector2(horizontalNumber * wallJumpClimb.x * 5f, wallJumpClimb.y));
  
             print("Pulei da esquerda");
         }
  
         isJumping = true;
         jumpTimeCounter = jumpTime;
  
         if (extraJumps < 0)
         {
             extraJumps = 0;
         }
  
         float gravity = -(2 * 3.5f) / Mathf.Pow(0.4f, 2);
         playerRb.velocity = (new Vector2(gravity * Time.deltaTime, gravity * Time.deltaTime));
     }

Here is the conditional to wallJump method:

         if (Input.GetButtonDown("Jump") && !grounded && !attacking && isWall)
         {
             wallJump();
         }


Both are on Update method.

In my FixedUpdate i have this:

     private void FixedUpdate()
     {
  
         grounded = Physics2D.OverlapCircle(groundCheck.position, checkRadius, whatIsGround);
         isWall = Physics2D.OverlapCircle(wallCheck.position, checkRadius, whatIsWall);
  
         horizontalNumber = Input.GetAxisRaw("Horizontal");
         verticalNumber = Input.GetAxisRaw("Vertical");
  
         if(!isWall)
         {
             playerRb.velocity = new Vector2(horizontalNumber * speedCharacter, playerRb.velocity.y);
         }
  
         interact();
  
     }

I'm new in unity and don't see what's wrong. If anyone can see why or maybe have a better method of doing this, it would be greatly appreciated.

The Result og this code: https://imgur.com/a/JUiFA56

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

0 Replies

· Add your reply
  • Sort: 

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

99 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

Related Questions

2D Platformer - How do I have objects that kill the player upon touch/cause respawn? 2 Answers

Unity 2D player sticks on platform corners 2 Answers

What are the best practices when importing 2D pixel sprites 1 Answer

Here when I hold D and then press w or space I don't know why my 2D character is not jumping and he falls off the given platform,I am not able to think how to fix this issue,please help 0 Answers

Inconsistent add force across PCs 0 Answers


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