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 Sushi271 · May 21, 2018 at 11:41 PM · physics2dplatformerbounciness

One-way bounciness

I'm developing 2D platform game. Using 2d box colliders & rigid bodies I have three kinds of objects:

  • a Character

  • a Crate

  • a Platform

Since I don't want Character to bounce off the Platform, but to stick to it, I set up both of their PhysicsMaterials to have Bounciness == 0. However I do want my Crate to bounce off the Platform when it falls from high enough, thus I decided to set its Bounciness to 0.2 (for now). The problem is that my Character bouncess off the Crate too now, which is undesirable.

It wouldn't be much of an issue, because it's hardly noticable at all... However it causes the falling animation for the Character launch several times. The trigger on the mecanim Animator that fires the animation is a bool parameter IsFalling, which I set to true, whenever Character's rigidbody's vertical velocity is lower than -0.001 (I had to put some threshold to avoid float precision causing my animation to fire).

It looks quite bad and I thought it's the best to address the root cause of the problem - my Character shouldn't bounce off the Crate at all. However from my research it seems that bounciness parameter of the Physics material always works two way and selects the net bounciness of any two objects following the maximum rule - the bigger one will be the bounciness for both of them. Unless there is a way to set this up somehow, of which I'm not aware?

The only thing I can think of now is just zeroing the vertical velocity of a Character once it lands on anything, but it looks like a bit of an workaround instead of addressing the real problem...

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 Bunny83 · May 22, 2018 at 12:16 AM

Well, unfortunately the 2d physics material doesn't have the combine options that the 3d physics material has. However the overall concept of having different results for the same collision is actually not physically correct. A collision is either elastic, inelastic or something in between. Therefore the result would correctly apply to both participants of a collision. So it seems that you can't get the 2d physics system to do that unrealstic behaviour you want. So zeroing the vertical velocity on collision might be the best solution.


See this question for reference

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 Sushi271 · May 22, 2018 at 03:53 AM 0
Share

Yeah... I figured this much after more thought... I ended up doing quite a crazy workaround with cases when should the vertical velocity be zeroed (it depends on whether it's really falling or not, or perhaps just started falling, or if it has just jumped or not; it also has a special case when the Character is not quite falling but it's on a steep slope and tries moving upwards (as it shouldn't be able to do so too)). The code behind is pretty complicated and I'm so not proud of it, but it's contained in one class that doesn't affect anything else, so at least it won't make mess in other parts. Encapsulation ftw. As for the link you provided, I already found somewhere that for 2D friction multiplies and bounciness get's the max. But it's nice to have it pictured like in that answer.

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

88 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

Related Questions

Hold to jump higher 0 Answers

Mobile platformer jump not working 2D 1 Answer

2d character horizontal movement 1 Answer

2D platformer landing problem? 1 Answer

Tilemap Collider/Composite Collider leaving gaps 2 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