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 Lucasr07 · Jun 03, 2019 at 02:51 PM · rigidbody2dslopesclimb

how to climb slopes without slipping the rigidbody?

I'm programming a game in 2d and I would very much like to find a formula that is simple and efficient to get the character to recognize the slopes and go up and down without slipping, I've searched a lot on the internet for something that can help but not successful still, if anyone can help me thank you too much!

I already found many similar doubts but I still did not find one that would answer me because I am relatively new with programming still.

Comment
Add comment · Show 5
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 Pangamini · Jun 04, 2019 at 01:55 PM 0
Share

Well, are you using any physics engine? Are you calculating the motion all by your code self?

avatar image Lucasr07 Pangamini · Jun 04, 2019 at 02:06 PM 0
Share

I'm using unity physics with rigidbody2D, I'm moving the character with Rigidbody.velocity

avatar image Pangamini Lucasr07 · Jun 04, 2019 at 02:25 PM 0
Share

Would it help to apply a lot of friction to the character?

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Lucasr07 · Jun 04, 2019 at 05:28 PM

Sorry if I'm not clear, I'm using google translate to communicate, because Brazilian and there is no material to study that explains it.

this video shows in practice what I would like to achieve: https://www.youtube.com/watch?v=cwcC2tIKObU

The explanation seems very complex, I tried to do it but I did not succeed.

explaining once more in detail: I have a character body that uses Rigidbody.velocity to move around and its collisor is a capsule. Both the character and the Ground have no friction material. When I go through inclinations I get too much to climb, and I slide when I stop adding speed. So what I would like to achieve would be basically a way to detect the slope of the ground and stabilize the body on top of it, so I can climb up and down without grabbing or slipping, as in platform games like Super Mario, Donkey Kong Country. I've been trying for a long time for a solution and thank you very much if anyone can help me!

alt text


sem-titulo.png (6.0 kB)
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
avatar image
0

Answer by Pangamini · Jun 05, 2019 at 08:28 AM

Well... if detection of the slope is what you want, then perhaps you could find out what are you colliding with, using OnCollisionEnter() and somehow decide if it's a slope or not. Since I am not sure about your game mechanic, whether slope is a special place (and the character is climbing it eg. with arope or a pickaxe) or if it's just a sloped surface where the character walks normally) it's up to you to define the slope. Could be a gameObject somehow explicitly marked to be a slope (having a component, name, tag, etc) or it could simply be any sloped surface, in which case you would be interested in the collision normal, a vector pointing away from the surface you are standing on. You could then see how much this normal deviates from UP vector (by using Vector dot product / )

BUT, if you are not really all that interested in detection of the slope and you simply want to walk on it without slipping, while keeping all the normal character's behaviour (and physics properties) thenthe easiest solution would be to add a strong friction to the character's collider (or perhaps the slope collider or both)

Comment
Add comment · Show 1 · 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 Lucasr07 · Jun 05, 2019 at 08:32 PM 0
Share

Actually I've tried using tags to detect if it's a slope or not but I did not get the results I wanted. The inclinations I refer to are common slopes in platform games that exist in any 2D game, would be basically deformations in the ground, for$$anonymous$$g mountains and descents. On the friction already tried also but then the body is unable to move normally due to the friction, I even tried to create a boolean to activate the friction only when I am stopped, but all these solutions palliative give a very amateur result. Well, anyway thank you very much for the tips, I'll go and try to see if I can get any ideas for this.

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

108 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

Related Questions

Rigidbody2D climbing 45 degrees slopes 2 Answers

Handling Slopes 0 Answers

problem with 2d movement down slopes 0 Answers

Rigidbody2D jumping off of slopes 0 Answers

Lerp doesnt seem to work 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