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
3
Question by keeps · Aug 04, 2017 at 08:55 PM · c#physicsphysics settingsphysics 2dphysics material

How can I make 2D physics bounce the same as the 'multiply' bounce combine mode as seen in 3D Physics materials

In 3D physics materials, we have the setting of 'Bounce Combine' which dictates how the two physics materials bounciness values combine together to determine the overall bounce of the collision. The choices are Average (of the two bounciness values), Minimum, Maximum, and Multiply which just multiplies the bounciness values together

Multiply is the mode I really want, but this setting of 'Bounce Combine' is just not available at all for 2D Physics materials, and the way it works by default is the equivalent of 'Maximum' in 3D.

One thing I tried to get multiplicative bounce was setting physics materials bounciness to 0 and instead use my own Bounce code:

 void OnCollisionEnter2D(Collision2D collision)
 {   
     float multipliedBounce = bounciness * collision.otherRigidbody.GetComponent<Phys>().bounciness;
     foreach (ContactPoint2D contact in collision.contacts)
     {
         Vector2 impactVelocity = contact.relativeVelocity;
         float velocityInNormalDirection = Vector2.Dot(impactVelocity, contact.normal);
         Vector2 force = contact.normal * velocityInNormalDirection * rb.mass * multipliedBounce;
         rb.AddForceAtPosition(force, contact.point, ForceMode2D.Impulse);
     }
 }

This kinda works, but I feel like I'm doing something wrong because it doesn't act the same as the equivalent bounciness on a normal physics material, it bounces less on flat ground, but sometimes goes chaotic when colliding with other dynamic things, especially with box shapes, who's contact points can be in the far corners of the shape.

I would like to know if I'm doing something wrong in this code, or if there's any other solution entirely. Thanks!

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

Answer by keeps · Aug 04, 2017 at 10:53 PM

Now i'm wondering if it's possible instead to set Phys Materials bounciness to 1, and just modify the resulting velocity on the collisions instead according to my own bounciness, that sounds simple enough for bouncing against immovable kinematic surfaces, but with multiple moving objects I'm not sure where to even begin

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

155 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

Related Questions

Making a soccer game, Need help with a good, realistic and efficient workflow. 0 Answers

Is it possible to put collision detection in an if statement? 0 Answers

How to stop a sphere that is using GetAxis from moving? (Roll-A-Ball Tutorial) 0 Answers

Bounce, gravity and velocity 1 Answer

Car will only turn right (& ignored collders) 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