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 /
  • Help Room /
avatar image
0
Question by Viredae · Feb 25, 2018 at 11:09 PM · programmingphysics2dwall jumpwalljump

implementing a wall jump

Hey folks, I'm trying to make a wall jump mechanic in 2D, so far I have the player clinging to the wall if I hold the directional button down, I want to press the jump button while I do that, and have it ignore the directional input and do the jump arc.

This is what I have so far:

 void wallClingingFun()
     {
 
         rb2d.velocity = new Vector2(0, 0f);
 
         wallCling = true;
         doubleJump = true;
 
         if (Input.GetButtonDown("Jump"))
         {
             wallCling = false;
 
             if (facingRight)
             {
                 facingRight = !facingRight;
                 rb2d.velocity = new Vector2(-25, 7);
                 wallJump = true;
             }
             else if (!facingRight)
             {
                 facingRight = !facingRight;
                rb2d.velocity = new Vector2(25, 7);
                 wallJump = true;
             }
         }
         

obviously, it's not working, and I'm not sure what the correct functions I should use to make it work.

Any ideas?

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
1
Best Answer

Answer by SwedishDerp · Feb 26, 2018 at 07:53 AM

Instead of using a 'velocity' function, try adding force to the rigidbody. When creating a basic jump function the 'AddForce' is commonly used :)

Example Script:

 rb2d.Addforce(transform.right * 30, ForceMode.Force);

And when jumping left you just put a "-" before the "transform.right" to jump in the opposite direction :)

 rb2d.Addforce(-transform.right * 10, ForceMode.Force);

This may or may not be a functional script but I suggest you google about adding force to a side direction and also experiment yourself!

Comment
Add comment · Show 7 · 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
avatar image Viredae · Feb 26, 2018 at 09:14 AM 0
Share

Still the same problem, the character doesn't actually jump away from the wall when I press the jump button.

avatar image PersianKiller Viredae · Feb 26, 2018 at 09:23 AM 0
Share

@Viredae,you want when the character collides with the wall,then he can jump or what?is it an endless runner?can you explain a little more or post a screenshot of your game.

avatar image Viredae PersianKiller · Feb 26, 2018 at 10:26 AM 0
Share

I have the character clinging to the wall when I hold the directional input, and I want to press the jump button while clinging to have the character ignore the input and jump away from the wall.

A$$anonymous$$A a wall jump, it's not rocket science.

Show more comments

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

85 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

Related Questions

Does anyone know how to add a Wall Jump + Slide in a 2D Platformer?,Does anyone know how to add a wall jump + slide? 0 Answers

How could I add "gravity" to a top-down shooter's bullet, such as in The Binding of Isaac? 0 Answers

I can not get my character to crouch? Character not sliding on walls? 0 Answers

How to move upward with wall jump and not be pulled down too quickly? 0 Answers

I have a walljump script but the walljump doesn't work right can someone help me? 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